Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  77] [ 6]  / answers: 1 / hits: 40239  / 13 Years ago, mon, january 9, 2012, 12:00:00

Are MicrosoftAjax.js, MicrosoftMvcAjax.js and MicrosoftMvcValidation.js obsolete as of ASP.NET MVC 3? I haven't been able to find much info on this on the web, but from what I've read it implies that these files were used in ASP.NET MVC 1-2, and were replaced by jquery.validate.min.js, jquery.unobtrusive-ajax.min.js and jquery.validate.unobtrusive.min.js. Is that correct? Do I still need the Microsoft files?


More From » ajax

 Answers
22

Yes, all Microsoft* helpers are obsolete in ASP.NET MVC 3. For me they have always been obsolete but now at least Microsoft made this official and replaced them with jQuery.



2 new functionalities have been introduced



<appSettings>
<add key=webpages:Version value=1.0.0.0/>
<add key=ClientValidationEnabled value=true/>
<add key=UnobtrusiveJavaScriptEnabled value=true/>
</appSettings>


The first is UnobtrusiveJavaScriptEnabled. This means that if you enable this functionality in your web.config (its enabled by default when you create a new ASP.NET MVC 3 application), all the Ajax.* helpers such as Ajax.BeginForm and Ajax.ActionLink will emit HTML5 data-* attributes on their respective DOM elements instead of mixing javascript with markup. Then you should include the jquery.unobtrusive-ajax.js script to your page which will parse those attributes and use jQuery to unobtrusively AJAXify them.



The second is ClientValidationEnabled which is also enabled by default. The same way unobtrusive javascript works, when you enable this setting all helpers that generate input fields will emit HTML5 data-* attributes on them. Then you include jquery.validate.js and jquery.validate.unobtrusive.js scripts to make them work, such as in your _Layout.cshtml. They must appear in this order, and they must be after jquery is loaded:



<script [email protected](~/Scripts/jquery-1.7.1.min.js) type=text/javascript></script>
<script [email protected](~/Scripts/jquery.validate.min.js) type=text/javascript></script>
<script [email protected](~/Scripts/jquery.validate.unobtrusive.min.js) type=text/javascript></script>


So in ASp.NET MVC 3 you can forget about all Microsoft* scripts. Remove them from your site. Delete those files.


[#88149] Saturday, January 7, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
admin

Total Points: 468
Total Questions: 103
Total Answers: 103

Location: Equatorial Guinea
Member since Sun, Feb 14, 2021
3 Years ago
admin questions
Tue, Dec 29, 20, 00:00, 4 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
Fri, Jul 31, 20, 00:00, 4 Years ago
Mon, Oct 14, 19, 00:00, 5 Years ago
Sun, Jun 16, 19, 00:00, 5 Years ago
;