jquery - HTML.BeginForm/Ajax.Begin Form not working in Partial View -
i have partial view contains table , data dynamically append table. when click on save button in form , controller method not firing.
please see below code 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 main page rendering partial view
<div id="cavitypartial"> @html.partial("cavitypartialview") </div>
i nou using othher form other this.
below controller code:
[httppost] public actionresult cavityupdate() { // logic } return redirecttoaction("cavity", "cavity", new { id = siteid }); }
can me on this?
enable submit button. remove 'disabled' property it.
edit: can't create form elements table rows. instead try following syntax:
<table> @foreach (var item in model.cbys) { <tr> <td> @using(ajax.beginform("cavityupdate", "cavity", new ajaxoptions { httpmethod = "post", insertionmode = insertionmode.replace, updatetargetid = "cavitypartial" })){ //your code <table> <tr> <td></td> </tr> </table> } </td> </tr> } </table>
Comments
Post a Comment