Referencing jQuery UI in ASP.NET MVC

jQuery is a very popular JavaScript library integrated into the ASP.NET MVC framework. jQuery UI is a toolkit built on top of the jQuery library. Those getting started with MVC wonder how to reference jQuery UI API in their ASP.NET MVC apps. Here’s a simple post that shows how to do so.

To add jQuery UI in our MVC 3 apps, we have to add two references. The first reference is to our jQuery UI file and the second to the CSS file which contains the jQuery UI theme to be used. Remember that jQuery UI will not function properly if the theme file is not referenced. Devs usually miss out this point.

Assuming you have created an ASP.NET MVC 3 app, go to Views > Shared > _Layout.cshtml. You will observe that a reference has already been created to the jQuery file. It’s a good idea to go to jQuery.com, fetch the latest version and replace this file with the latest version in the Scripts folder or simply use a non-version file.

Here’s what it looks like after all the references have been added

image

You can customize this theme by using the jQuery UI ThemeRoller tool.

Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

1 comment:

sumitmaitra said...

Manual reference in days of Nuget? Naah!!! ;-)