我的控制器同时被调用两次,我不知道代码有什么问题
控制器:
List<Item> lstItems = new List<Item>();
public ActionResult _SaveItem(ItemDetails model)
{
Item it = new Item();
it.ItemName = model.itemName;
it.ItemURL = model.itemUrl;
it.Notes = model.Notes;
it.Price = model.unitprice;
it.Quantity = model.quantity;
it.Size = model.Size;
it.Weight = model.weight;
it.CategoryID = model.CategoryID;
it.Color = model.color;
lstItems.Add(it);
return PartialView(it);
}
查看:
@model CSP1225.Models.ItemDetails
@using (@Ajax.BeginForm("_SaveItem", "Order", new AjaxOptions { InsertionMode = InsertionMode.InsertAfter, UpdateTargetId="Items" }))
{
<div id="Items">
</div>
<div class="form-horizontal" style="padding-left:20px;" >
@Html.EditorForModel()
<input type="Submit" id="addItem" value="Add Item" name="addItem" />
</div>
}
任何帮助请... ??
答案 0 :(得分:0)
实际上我包括jquery.unobtrusive-ajax
两次,这就是代码同时调用两次的原因:)