我有一个部分由Ajax调用来添加新的订单项。如果我在部件ID字段中输入一些数据,然后单击添加另一个项目的链接,它会清除我刚输入的内容。
查看:
<label>Parts Used
<%= Ajax.ActionLink("Add another item", "BlankEditor", new AjaxOptions {
UpdateTargetId = "partusageitems", InsertionMode = InsertionMode.InsertAfter}) %>
</label>
<div id="partusageitems">
<% foreach (var part in Model.PartUsage)
{
Html.RenderPartial("~/Views/Fsr/_PartsUsage.ascx", part);
}%>
</div>
部分:
<div>
<% var fieldPrefix = "PartUsage[]."; %>
Part ID: <%= Html.TextBox(fieldPrefix + "ID", Model.ID, new { size = "25"})%>
Serial Number: <%= Html.TextBox(fieldPrefix + "Serial", Model.Serial, new { size = "25" })%>
Quantity: <%= Html.TextBox(fieldPrefix + "Quantity", Model.Quantity, new { size = "10"}) %>
<a href="#partsusagesection" onclick="deleteContainer(event)">Delete</a>
</div>
控制器:
public ActionResult BlankEditor()
{
return View("_PartsUsage", new Part());
}
答案 0 :(得分:0)
这可能只是一个拼写错误,但Partial在结尾处缺少DIV结束标记。