Whne adding a confirmation box to the checkbox (when its value changed from checked to unchecked), the checked change event will not load.
Any suggestions?
Any suggestions?
Code:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<script runat="server">
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == false)
{
Response.Write("Checkbox changed value");
}
}
protected void Page_Load(object sender, EventArgs e)
{
CheckBox1.Attributes.Add("onclick", "if (!this.checked) {return confirm('Please confirm'); }");
}
</script>
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack=true />
</div>
</form>
</body>
</html>