I have a checkbox on a form:
<asp:CheckBox ID="CheckBox1" runat="server"
Visible="true" AutoPostBack="True" oncheckedchanged="CheckBox1_CheckedChanged" />
It is not firing the below event when I check or uncheck it.
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
preContactTextBox.Visible = true;
prePracticeCodeTextBox.Visible = true;
}
else
{
preContactTextBox.Visible = false;
prePracticeCodeTextBox.Visible = false;
}
}
It is not entering this event at all. What I am doing wrong?
here’s the complete code:
How can I get it to fire the event?
I think the postback is not firing due to the niceforms plugin you are using. It seems the plugin is overriding the default functionality of the checkbox.
To test if this is the case trying removing the
class="niceform"attribute from your form tag.Due to the fact that smartforms override the onclick event, as far as I can tell the only way to resolve this is to modify the source of the niceforms plugin by replacing the inputCheck function with the following. I have tested this and it worked for me.
Hope this helps.