0

从演示解决方案中,我尝试使用内置的 mvc ajax 功能。但由于某种原因,部分视图没有被替换。

@using (Ajax.BeginForm("RefreshPartial", "Home",  new AjaxOptions() { UpdateTargetId = "PartialToRefresh", HttpMethod = "Post" }))
{ 
    @Html.TextBox("Name");
    <input type="submit" value="Send name" />
}
<br />
<div>
    @Ajax.ActionLink("Just refresh", "RefreshPartial", "Home", null, new AjaxOptions() { UpdateTargetId = "PartialToRefresh", HttpMethod = "Post" }, null)
</div>
<br />
<div id="PartialToRefresh">
    @Html.Partial("_DateTimePartial", "test")
</div>
4

1 回答 1

0

当我显示 HTML 页面时,我得到了这个 html 代码

<form action="/Home/RefreshPartial" id="form0" method="post" onclick="Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'Post', updateTargetId: 'PartialToRefresh' });">                       
    <input id="Name" name="Name" type="text" value="">    
    <input type="submit" value="Send name">
</form>

经过一番谷歌搜索后,我发现 web.config 将不显眼的标志设置为 false。

  <appSettings>
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="false"/> 
  </appSettings>

这必须 OFFCOURSE 是真的!:)

于 2012-12-07T11:29:01.917 回答