shreyas R S

shreyas R S

  • NA
  • 1
  • 2.5k

javascript to check if checkbox is checked asp.netuser cntrl

Mar 14 2013 3:03 PM
Hi All,

I have a html checkbox control and Button in my User control.

Now i need to check whether checkbox is checked when button is clicked.

I am using the below code. But it does not work :(



In webusercontrol1.ascx,

<script type="text/javascript">
$(document).ready(function () {
$("input[id*=remember]").change(function () {
debugger;
if (this.checked)
alert("its checked");
else
alert("notchecked");
});
});
</script>


<table>
<tr>
<td>
<input id="remember" name="remember" type="checkbox" />
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</td>
</tr>
</table>

In webusercontrol1.ascx.cs,

protected void Button1_Click(object sender, EventArgs e)

{

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "function();", true);

// my rest of the code once checkbox is clicked

}

Answers (1)