异步提交后会把input标签删除吗?附图:异步提交前:
异步提交后(只剩下submit按钮):
@model SCTK.Models.ClassType
@{
AjaxOptions ajaxOpts = new AjaxOptions
{
UpdateTargetId = "tabledata",
Url = Url.Action("AddClassType"),
OnSuccess = "OnSuccess"
};
}
@using (Ajax.BeginForm(ajaxOpts))
{
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
<table id="tabledata">
<tbody>
<tr>
<td>
显示分类名:
</td>
<td>@Html.EditorFor(_ => _.ShowName)
</td>
<td>@Html.ValidationMessageFor(x=>x.ShowName)</td>
</tr>
<tr>
<td>
真实分类名:
</td>
<td>@Html.EditorFor(_ => _.TrueName)
</td>
<td>@Html.ValidationMessageFor(x=>x.TrueName)</td>
</tr>
<tr>
<td>
添加人:
</td>
<td>
xxxxx
</td>
</tr>
@Html.HiddenFor(_ => _.ParentID)
@Html.HiddenFor(_ => _.Deep)
</tbody>
</table>
<input type="submit" value="submit" />
UpdateTargetId = "tabledata"
去掉或用另外一个控件。
不是自动删除,是你设置了UpdateTargetId为tabledata,提交后它将返回的结果显示在tabledata里导致它里面的内容都被干掉了,你先搞清楚UpdateTargetId 什么意思再用它。