How Can I Call A Javascript Function When Checkbox Is Checked
How can I call a Javascript function when a checkbox is checked when this checkbox is inside a gridview ? protected void AlteraStatusExpiraSeteDias_Click(object sender, EventArgs e
Solution 1:
Add onclick
attribute to Checkbox markup and include the javascript function that you'd like to call.
<asp:CheckBoxID="chkExpiraTresDias"runat="server"onclick="alert('Foo')" />
Solution 2:
this should help you
$('input:checkbox[ID$="chkExpiraTresDias"]').change(function() {
alert('Hello world!');
});
Solution 3:
I fear that you will have to iterate through the Gridview when your "Insert" button is clicked and then do what you have to do. Something like this:
foreach (GridViewRow row inthis.grdImoveis2.Rows) {
if (row.RowType == DataControlRowType.DataRow) {
CheckBox chk = row.Cells(0).FindControl("chkExpiraTresDias");
if (chk != null) {
Response.Write(chk.Checked); //Do what you gotta do here if it's checked or not
}
}
}
Good luck.
Hanlet
Post a Comment for "How Can I Call A Javascript Function When Checkbox Is Checked"