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先感谢您的帮助。