js的情况下使用MicrosoftMvcValidation

js的情况下使用MicrosoftMvcValidation

本文介绍了如何在不包含MicrosoftAjax.js的情况下使用MicrosoftMvcValidation.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要使用jQuery,似乎在MVC 2 RC1中存在问题.请验证,但不要使用主要的Microsoft AJAX-即使gzip压缩也要25kb.

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.

根据Phil Haack的说法,您应该能够只包括这些脚本:

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">

不幸的是,他们在Beta和RC之间进行了一些重组-您现在还需要包含 MicrosoftAjax.js ,该文件定义了 Type 原型函数,这些原型函数由使用MicrosoftMvcJQueryValidation.js (第一行是 Type.registerNamespace('Sys.Mvc'); ,在 MicrosoftAjax.js 中定义)

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)

是否有人已经从所需的 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!

推荐答案

啊哈!

看起来像 MicrosoftMvcValidation.js 并不是 jQuery.validate 所需的文件.

Looks like MicrosoftMvcValidation.js is NOT the file needed for jQuery.validate.

您需要使用名称非常相似的 MicrosoftMvcJQueryValidation.js .这与 Microsoft.Ajax.js 无关.

You need to use the very similarly named MicrosoftMvcJQueryValidation.js. This has no dependency on Microsoft.Ajax.js.

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

这篇关于如何在不包含MicrosoftAjax.js的情况下使用MicrosoftMvcValidation.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 22:18