ASP.NET MVC 3 adds some significant support for client-side development, following current standards for top quality JavaScript integration in the following aspects:

Unobtrusive JavaScript

MVC 3 supports unobtrusive JavaScript in two ways:

– Ajax helpers (such as Ajax.ActionLink and Ajax.BeginForm) render clean markup for the FORM tag, wiring up behavior leveraging extensible attributes (data- attributes) and jQuery.

– In MVC 3 the markup is lighter weight, and the use of data- attributes makes it easier to leverage and reuse the validation information using jQuery or other JavaScript libraries.

 

jQuery validation

MVC 2 shipped with jQuery, but used Microsoft Ajax for validation. MVC 3 completed the transition to using jQuery for Ajax support by converting the validation support to run on the popular jQuery Validation plugin. The combination of Unobtrusive JavaScript support and jQuery validation using the standard plugin system means that the validation is both extremely flexible and can benefit from the huge jQuery community.

Client-side validation is now turned on by default for new MVC 3 projects, and can be enabled sitewide with a web.config setting or by code in global.asax for upgraded projects.

 

JSON Binding

MVC 3 includes JSON (JavaScript Object Notation) binding support via the new JsonValueProviderFactory, enabling your action methods to accept and model-bind data in JSONformat. This is especially useful in advanced Ajax scenarios like client templates and data binding that need to post data back to the server.