I have a partial view which contains table and data is dynamically append to that table. When i click on save button in that form , my controller method is not firing.
Please see the below code for my partial view.
<div id="cavitypartial">
<table id="CTable" class=" table table-bordered">
<tr>
<th></th>
<th>C Name</th>
<th>Number of C</th>
@foreach (var item in Model.PLByS)
{
<th>@item.PLName (CT/sec)</th>
}
<th>Comments</th>
</tr>
@foreach (var item in Model.CByS)
{
//using (Html.BeginForm("CavityUpdate", "Cavity", FormMethod.Post, new { id = "tblCavity" }))
using (Ajax.BeginForm("CavityUpdate", "Cavity", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "cavitypartial" }))
{
<tr id="@item.CavityID">
<td><a onclick='DeleteRow(this,@item.CavityID);'><img src='/Content/Images/trash_empty.png' class='btndelete' alt='x' /></a><a onclick='EditRow(this,@item.CavityID);'><img src='~/Content/Images/edit.png' class='btndelete' alt='x' /></a></td>
<td><input type="text" id="cn_@item.CavityID" name="cn_@item.CavityID" value="@item.CavityName" disabled /></td>
<td><input type="text" id="cp_@item.CavityID" name="cp_@item.CavityID" class="addcavity" value="@item.NumberOfParts" disabled /> <input type="hidden" id="h_@item.CavityID" name="h_@item.CavityID" /> </td>
@foreach (var Cavitem in Model.Cavities)
{
if (item.CavityID == Cavitem.CavityID)
{
<td><input type="text" id="c_@(item.CavityID)p_@(Cavitem.ProductLineID)" name="c_@(item.CavityID)p_@(Cavitem.ProductLineID)" class="addcavity" value="@Cavitem.Time" disabled /></td>
}
}
<td><input type="text" id="cn_@item.CavityID" name="cc_@item.CavityID" value="@item.comments" disabled /> <input type="hidden" id="h_@item.CavityID" name="h_@item.CavityID" /> </td>
<td id="Savecommand"><input type="submit" id="btnS_@item.CavityID" value="Save" /></td>
<td id="Savecommand"><input type="button" id="btnC_@item.CavityID" onclick="cancelEditing(this,@item.CavityID);" value="Cancel" /></td>
</tr>
}
}
</table>
</div>
Below is the Main page where am rendering Partial View
<div id="cavitypartial">
@Html.Partial("CavityPartialView")
</div>
I am nou using any othher form other than this.
Below is the controller code:
[HttpPost]
public ActionResult CavityUpdate()
{
// logic
}
return RedirectToAction("Cavity", "Cavity", new { id = siteid });
}
Can anyone help me on this?