这是我的看法:
@foreach(var item in Model) {
<tr id="TR@(item.Id)">
@{Html.RenderPartial("_PhoneRow", item);}
</tr>
}
_PhoneRow
:
@model PhoneModel
@using(Ajax.BeginForm("EditPhone", new { id = Model.Id }, new AjaxOptions {
UpdateTargetId = "TR" + Model.Id
})) {
<td>@Html.DisplayFor(modelItem => Model.PhoneNumber)</td>
<td>@Html.DisplayFor(modelItem => Model.PhoneKind)</td>
<td><input type="submit" value="Edit" /></td>
}
控制器:
public ActionResult EditPhone(long Id) {
//Get model by id
return PartialView("_EditPhoneRow", model);
}
public ActionResult SavePhone(PhoneModel model) {
//Save Phone, and Get Updatet model
return PartialView("_PhoneRow", model);
}
_EditPhoneRow
@model PhoneModel
@using(Ajax.BeginForm("SavePhone", new { id = Model.Id }, new AjaxOptions {
UpdateTargetId = "TR" + Model.Id
})) {
<td>@Html.EditorFor(modelItem => Model.PhoneNumber)</td>
<td>@Html.EditorFor(modelItem => Model.PhoneKind)</td>
<td><input type="submit" value="Save" /></td>
}
所以,当我点击Edit
按钮的_EditPhoneRow
完美替代,但后来当我点击Save
按钮没有任何get,在不工作的问题?更新了新的局部视图行为什么当新的Ajax形式? 我觉得这个问题是非常受欢迎的,我只需要编辑,保存阿贾克斯的任何行,你有什么建议吗? 或任何来源或为它好样?