Trouble getting value from Checkbox in Firefox
I have the following checkbox
<form id="Form1" runat="server">
<p class="hint grey"><asp:checkbox runat="server" ID="chkBox"/><asp:literal runat="server" ID="warningTxt"></asp:literal></p>
<div class="clear"></div>
<br/>
<table>
<tr><td>
<asp:ImageButton ID="btnSubmit"
runat="server"
Text="Agree"
ToolTip="Agree"
UseSubmitBehavior="true"
OnClick="btnSubmit_Click"
CausesValidation="true"
ImageUrl="~/img/buttons/agree-button.gif" />
</td><td>
<a href="#" onclick="window.print();return false;"><img src="img/buttons/print-button.gif"/></a>
</td></tr></table>
</form>
And in code behind
protected void btnSubmit_Click(object sender, EventArgs e)
{
ErrorMessage.Text = String.Empty;
DateTime currentDate = DateTime.Now;
if (Page.IsValid)
{
if (chkBox.Checked)
{
Response.Redirect("Default.aspx", false);
}
else
{
ErrorMessage.Text = "Tick the alert statement";
开发者_JS百科 ErrorMessage.CssClass = "error";
//errorTable.Visible = true;
}
}
}
Now for some reason in Firefox, when I tick the box and click on submit I get the error message "Tick the alert statement", but its fine in Chrome. So just why firefox isnt picking up the value in checkbox correct ?
Try removing the CausesValidation="true"
attribute. Its the only thing I can see that could be causing problems.
精彩评论