<%=Ajax.ActionLink("动态", "Index", "Index", new { id = 1 }, new AjaxOptions() { LoadingElementId = "Loading", UpdateTargetId = "Main", HttpMethod = "Get", OnFailure = "dialogOpen" })%>
解析正确的话:
<a href="/Manager/1" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: ‘Get‘, loadingElementId: ‘Loading‘, updateTargetId: ‘Main‘, onFailure: Function.createDelegate(this, dialogOpen) });">动态</a>
不正确的话:
<a data-ajax="true" data-ajax-failure="dialogOpen" data-ajax-loading="#Loading" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-update="#Main" href="/Manager/1">动态</a>
看到这里,应该可以看出,一个是MVC2的代码解析,一个是MVC3的代码解析。
到网上看一下MVC3的新特性,就可以知道:
多了一个新特性Unobtrusive JavaScript
解决方案:Web.config
[c-sharp] view plaincopy
- <configuration><appSettings> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> </appSettings></configuration>
把true改成false就可以啦!
<add key="UnobtrusiveJavaScriptEnabled" value="false"/>
时间: 2024-10-19 17:34:48