在使用 MVC3 razor 进行示例时,我写道:
<p>
Show me the time in:
@Ajax.ActionLink("UTC", "GetTime", new { zone = "utc" }, new AjaxOptions { UpdateTargetId = "myResults" })
@Ajax.ActionLink("BST", "GetTime", new { zone = "bst" }, new AjaxOptions { UpdateTargetId = "myResults" })
@Ajax.ActionLink("MDT", "GetTime", new { zone = "mdt" }, new AjaxOptions { UpdateTargetId = "myResults" })
</p>
<div id="myResults" style="border: 2px dotted red; padding: .5em;">
Results will appear here
</div>
<p>
This page was generated at @DateTime.UtcNow.ToString("h:MM:ss tt") (UTC)
</p>
在我更改 web.config 中的这个键之前,我的 ajax 调用都不起作用:
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
我在这篇文章中读到:http
://weblogs.asp.net/owscott/archive/2010/11/17/mvc-3-ajax-redirecting-instead-of-updating-div.aspx
但现在我的客户端验证不像以前那样工作。
我的问题是:如何使 ajax 和客户端验证同时工作?“UnobtrusiveJavaScriptEnabled”有什么作用?难道是他们之间的切换?!我希望用简单的术语来更多地了解它。