Fire onCheckChanged event of CheckBox from jQuery aspnet -
i have checkbox field in gridview in aspnet webform. upon user checking / unchecking each checkbox, want run server side code oncheckedchanged event checkbox using jquery.
the gridview loads in jquery popup window this
<div id="dialog" style="display: none"> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" onpageindexchanging="onpageindexchanging" datakeynames="id" pagesize="10" allowpaging="true"> <columns> <asp:templatefield> <itemtemplate> <asp:checkbox id="chk" runat="server" text="select" oncheckedchanged="oncheckchanged" /> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="id" headertext="id" itemstyle-width="100" /> <asp:boundfield datafield="name" headertext="name" itemstyle-width="300" /> <asp:boundfield datafield="description" headertext="description" itemstyle-width="400" /> </columns> </asp:gridview> </div>
jquery this
$(document).ready(function () { $("input:checkbox").click(function () { if ($(this).is(":checked")) { $(this).trigger('oncheckchanged',true); } else { alert("false"); } }); });
my "checkchanged" event this
sub oncheckchanged(sender object, e eventargs) dim chk checkbox = trycast(sender, checkbox) dim row gridviewrow = trycast(chk.namingcontainer, gridviewrow) dim pk string = gridview1.datakeys(row.rowindex).values(0).tostring if chk.checked = true 'do else 'do end if end sub
the jquery function works when checkbox unchecked. not fire server side oncheckchanged event
can help?
$(document).ready(function () { $("input[type=checkbox]" ).click(function () { if ($(this).is("input:checked")) { $(this).trigger('oncheckchanged',true); } else { alert("false"); } }); });
Comments
Post a Comment