# Friday, 29 June 2012

A great new feature in ASP.NET MVC is the ability to bundle scripts and CSS files and register them as a group.  More detail on this functionality can be found here.  Because by default all the scripts and CSS classes in a new MVC 4 project are registered using bundles I felt a little dirty in my previous posts referencing my Kendo UI scripts and CSS files each individually.  I rectified that.

So I started the rectification process by adding entries to the BundleConfig.cs.  In this file is where you create and configure your bundles.  Out of the box there are a number of bundles configured so all I needed to was follow the same conventions when creating my bundles. 

bundles.Add(new ScriptBundle("~/bundles/kendojs").Include(
            "~/Scripts/jquery.min.js",
            "~/Scripts/kendo.all.min.js"));
 
bundles.Add(new StyleBundle("~/Content/kendocss").Include(
            "~/Content/kendo.common.min.css",
            "~/Content/kendo.default.min.css"));

Obviously I took the least amount of scripts I needed to get my contrived sample created, but you can add whatever scripts you need.

After creating the bundles I need to register or “Render” them as the method is called.  Have to admit I am not a fan of “Render” as the method name.  In the past “Render” has always had a visual connotation.  The registering of the bundles for this example is taking place in the _layout.cs, but you could do the same thing directly in your ASP.NET MVC View.

@Styles.Render([...other CSS bundles], "~/Content/kendocss")
@Scripts.Render([...other Script bundles],"~/bundles/kendojs")

And that’s it.  Now I have my Kendo UI scripts and CSS files registered/referenced/rendered using the new bundling features of ASP.NET MVC

Code is available on GitHub.

Thursday, 05 July 2012 16:39:59 (Central Daylight Time, UTC-05:00)
And here I have to go show my ignorance on the first post in this series. Thanks for pointing this out and helping me to "LEARN2READ". Oh, and disregard my post on your first article in this series.
Brett Baggott
Friday, 06 July 2012 06:51:58 (Central Daylight Time, UTC-05:00)
Brett,
Thanks for reading and commenting!
As for your initial question, I typically simplify my blog posts to make them easier to follow and often in the case of that post have a follow up post on making the initial code more *enterprisey*. What I should have done is gone back and updated the original post with a link to the other post, and I will do that.
Thursday, 16 August 2012 09:23:05 (Central Daylight Time, UTC-05:00)
I tried to do that in VS 2010 and I cannot force to make kendow rendered from bundle. Tried differen things, and it is never rendering.
Marcin
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview