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.
You should add the AutoPostBack=True
attribute to both controls.
you have to specify the AutoPostBack=True
for both controls
I would use RadioButtonList
instead. And set AutoPostBack=true
for what you want to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With