0
我試圖在表單提交後替換<div>
內容。這裏是代碼(這是部分視圖):ASP .NET MVC 2. InsertionMode.Replace in AjaxOptions dosent work right
<% using (Ajax.BeginForm("Authenticate", "User", new AjaxOptions { HttpMethod = "post", UpdateTargetId = "authPanel", InsertionMode = InsertionMode.Replace}))
{%>
<label>Username</label><%= Html.ValidatedTextBoxFor(username => Model.UserAuthienficateDto.Username, false) %>
<label>Password</label><%= Html.ValidatedTextBoxFor(password => Model.UserAuthienficateDto.Password, false) %>
<input name="Input" type="submit" class="button" value="Authenticate" />
<%}%>
<div id="authPanel">
<ul>
<% if (HttpContext.Current.User.Identity.IsAuthenticated)
{%>
<li class="nonregister">Logged in as <%=HttpContext.Current.User.Identity.Name%></li>
<li class="register"><%= Html.ActionLink("Logout", "Logout", "User")%></li>
<%
}%>
<% else
{%>
<li class="nonregister">Not a member ?</li>
<li id="userRegisterDialogOpener" class="register">Sign up now!</li>
<%}%>
</ul>
</div>
問題是,表單提交後,我得到了整個局部視圖重新呈現。而且所有的結果都被渲染在舊的結果之上(儘管它們有一些偏移)。爲什麼InsertionMode.Replace工作不正常? Mant先感謝您的幫助。