I am trying to figure out why this code doesn’t fire the radio button change event.
here’s the ASP page code for 2 radio buttons
<asp:RadioButton ID="rdoButton1" GroupName="Group1" Text="Yes" Value="Yes" runat="server" OnCheckedChanged="Group1_CheckedChanged" />
<asp:RadioButton ID="rdoButton2" GroupName="Group1" Text="No" Value="No" runat="server" OnCheckedChanged="Group1_CheckedChanged" />
And here’s the code behind:
protected void Group1_CheckedChanged(Object sender, EventArgs e)
{
if (rdoButton1.Checked) {
panel1.Visible = true;
}
if (rdoButton2.Checked) {
panel1.Visible = false;
}
}
You’ll need to specify the attribute and value
AutoPostBack="true"in order to tell ASP.NET that changing of that element should trigger a postback. It should be applied to each individual RadioButton which you wish to cause a postback.