Thursday, November 14, 2013

How to use bundle for Javascript and css in ASP.NET MVC?

1. Define bundle:
    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));
            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.js"));
 }
     }
2. Register Bundle:
In Global.asax
        protected void Application_Start()
        {
            BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
3. Refer bundle
In Razor view
    @Scripts.Render("~/bundles/jquery")

"display: inline-block" (Items does not display horizontally) not working in IE

Change to:
display: inline;
Reference:
http://stackoverflow.com/questions/5838454/inline-block-doesnt-work-in-internet-explorer-7-6

How to implement multiple [Order by] in LINQ?

Var list = _db.Lists.Orderby(c => c.filed1).ThenBy(n => n.field2)