tags:

views:

1082

answers:

2

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 MicrosoftMvcJQueryValidation.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!

+1  A: 

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.

Yuriy Faktorovich
i already have too many javascript files i need. this is my limit for sure. plus its definitely kind of a bug - albeit easy to fix. plus hopefully people will find this and understand the problem sooner
Simon_Weaver
+5  A: 

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.

Simon_Weaver
The futures project has moved to: http://aspnet.codeplex.com/releases/view/41742, the script is also available in the MVC 2 Source Code download
Ulf Lindback