ASP.NET MVC 3中的MicrosoftAjax.js,MicrosoftMvcAjax.js和MicrosoftMvcValidation.js是否过时?(Are MicrosoftAjax.js, MicrosoftMvcAjax.js and MicrosoftMvcValidation.js obsolete as of ASP.NET MVC 3?)
ASP.NET MVC 3中的MicrosoftAjax.js , MicrosoftMvcAjax.js和MicrosoftMvcValidation.js过时? 我无法在网络上找到很多信息,但是从我所看到的,这意味着这些文件在ASP.NET MVC 1-2中使用,并被jquery.validate.min.js替换, jquery.unobtrusive-ajax.min.js和jquery.validate.unobtrusive.min.js 。 那是对的吗? 我还需要Microsoft文件吗?
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?
原文:https://stackoverflow.com/questions/8782697
更新时间:2019-08-08 05:09
最满意答案
是的,所有的Microsoft*帮助者在ASP.NET MVC 3中都已经过时了。对我来说,他们一直都是过时的,但现在至少微软做了这个官方,并用jQuery代替它们。
已经引入了2个新功能
第一个是UnobtrusiveJavaScriptEnabled 。 这意味着如果您在web.config中启用此功能(默认情况下,当您创建一个新的ASP.NET MVC 3应用程序时启用此功能),所有Ajax.*帮助器(如Ajax.BeginForm和Ajax.ActionLink将会发出HTML5数据 - *属性在各自的DOM元素,而不是混合javascript与标记。 然后,您应该将jquery.unobtrusive-ajax.js脚本包含在您的页面中,该脚本将解析这些属性,并使用jQuery来显式地AJAXify它们。
第二个是ClientValidationEnabled ,默认情况下也启用。 同样的方式,不引人注目的JavaScript可以工作,当您启用此设置时,生成输入字段的所有帮助器将会在其上发出HTML5数据 - *属性。 然后,您可以包含jquery.validate.js和jquery.validate.unobtrusive.js脚本,使其工作,例如在_Layout.cshtml中。 它们必须按此顺序显示,并且必须在jquery加载之后:
所以在ASp.NET MVC 3中你可以忘记所有的Microsoft*脚本。 从你的网站上删除它们。 删除这些文件。
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
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:
So in ASp.NET MVC 3 you can forget about all Microsoft* scripts. Remove them from your site. Delete those files.
相关问答
MVC3支持两种客户端验证模式: 使用MicrosoftMvcValidation.js的经典验证 要启用此功能,请在Html.BeginForm()之前调用Html.EnableClientValidation() Html.BeginForm() 。 使用jquery.validate.js和jquery.validate.unobtrusive.js(MVC3新增)的不显眼验证 要启用此功能,请将以下settinsg添加到Web.config中:
...
你是否包括所需的javascript文件? 你需要: jQuery的1.4.1.js jquery.validate.js jquery.validate.unobtrusive.js(如果使用不显眼的验证) Are you including the required javascript files? You need: jquery-1.4.1.js jquery.validate.js jquery.validate.unobtrusive.js (if using unobtrusive
...
是的,所有的Microsoft*帮助者在ASP.NET MVC 3中都已经过时了。对我来说,他们一直都是过时的,但现在至少微软做了这个官方,并用jQuery代替它们。 已经引入了2个新功能
'>
I would look at the paths for the javascript incl
...