This is My View:
@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>
}
Controller:
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>
}
So When I click Edit
Button the _EditPhoneRow
Replaced Perfectly, but then when I click on Save
button there is not any get, where is the problem?, why when updated the row with new partial view the new Ajax form not working? I think this issue is very popular, I just need Edit-Save With Ajax in any row, what is your suggestion? or any source or good sample for it?