ASP.NET MVC 2 projects default script files. What are you using?
Many js files are included by default in the Scripts folder in ASP.NET MVC 2 projects. I suppose developers use jquery almost every time they program a site, but what about other files?
Please tell me the scenarios and reasons for when you:
- Use Microsoft.Ajax instead of jquery, or mix both libraries.
- Use jQuery validation framework instead of asp.net mvc one, or combine them like
Thank you in advance!
PS there are also different versions of the same file. Will you include different versions depending on the debug / release build?
a source to share
I would never mix two JavaScript libraries (MicrosoftAjax and jQuery) in the same project. Besides the added upload (your users will have to upload twice as many JavaScript files), there is quite a bit of duplication - two ajax implementations, two validation implementations, etc. As we all know, DRY is a good thing to follow.
For me, the only benefit of using MicrosoftAjax in an ASP.NET MVC project is that it has built-in server-side support - Ajax.Form
, Ajax.ActionLink
etc. Its built-in client validation is also used.
However, all of these things can be done with jQuery and from my experience I think jquery.validate works great with data annotations. I haven't found any problems yet.
a source to share
I can't find a reason to prefer the Microsoft AJAX library over jQuery. The same goes for verification. Also I would recommend that you use a CDN to serve static files like jquery
and jquery.validation
. So start by deleting everything in the folder Script
and only add the scripts you write yourself.
a source to share
I usually delete this folder and create a new one under Content with only jquery. I feel more comfortable working with jquery instead of Microsoft's ajax implementation, so I don't need a script file related to Microsoft.Ajax.
And about validation, I like to use jquery.validate for client side validation and server side data model validation. In MVC1, you would have to get around both using a framework like xVal, but you haven't done so in mvc2 yet.
a source to share