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.




About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

1 comment:

Anonymous said...

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