How do I use MicrosoftMvcValidation.js without having to include MicrosoftAjax.js?
It looks like there's an issue in MVC 2 RC1 if you want to use jQuery.Validate but not the main Microsoft AJAX - which is 25kb even when gzipped.
According to Phil Haack you're supposed to be able to just include these scripts:
<script src="/Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript">
Unfortunately in some reorganization they did between Beta and RC - you also now need to include MicrosoftAjax.js
which defines the Type
prototype functions that are used by Mic开发者_如何学JAVArosoftMvcJQueryValidation.js
(the first line is Type.registerNamespace('Sys.Mvc');
which is defined in MicrosoftAjax.js
)
Has anyone already extracted out the necessary code from MicrosoftAjax.js
that is needed?
I'll have to do it sooner or later but if anyone has already done it that would help a lot!
Aha!
Looks like MicrosoftMvcValidation.js
is NOT the file needed for jQuery.validate
.
You need to use the very similarly named MicrosoftMvcJQueryValidation.js
. This has no dependency on Microsoft.Ajax.js
.
The latest version of MicrosoftMvcJQueryValidation.js
is available in the futures download project. It isn't included in the normal download - hence my confusion.
Instead of jumping through hoops to get this working, you might want to look into letting Microsoft/Google serve the AJAX library for you. This would likely give you a speed advantage. And a good chance that the library will already exist on the client's machine.
精彩评论