Click here to Skip to main content
15,883,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends..

I have a two radio buttons in a page.


When i am select first radio button the panel 1 will be displayed.

When i am select Second radio button the panel 2 will be displayed.

How can i do this.

ASP.NET
<td>
                    <asp:DropDownList ID="drop" runat="server" OnSelectedIndexChanged="drop_SelectedIndexChanged"
                        AutoPostBack="True">
                        <asp:ListItem Text="Select"> </asp:ListItem>
                        <asp:ListItem Text="Full Day"> </asp:ListItem>
                        <asp:ListItem Text="Half Day"> </asp:ListItem>
                        <asp:ListItem Text="Leave"> </asp:ListItem>
                    </asp:DropDownList>
                    <asp:RadioButton ID="radio" Text="FN" runat="server" />
                    <asp:RadioButton ID="radioAN" Text="AN" runat="server" AutoPostBack="True" />
                     
                </td>
Posted
Comments
Rahul Rajat Singh 31-May-12 6:58am    
you want to do this on cleint side or server side. i mean can you affrod a postback or not?

You have

XML
<asp:RadioButton ID="radio" Text="FN" runat="server" AutoPostBack="True" />
                    <asp:RadioButton ID="radioAN" Text="AN" runat="server" AutoPostBack="True" />



Try This Code in Page Load Event it will work or you can genrate selection changed event of RadioButton

C#
//For Event you can write this in radio Selection changed Event
If(radio.Checked)
{
Panel1.visible=true;
}
else
{
Panel2.visible=false;
}
//For Event you can write this in radioAN Selection changed Event
If(radioAN.Checked)
{
Panel1.visible=false;
}
else
{
Panel2.visible=true;
}
 
Share this answer
 
v2
First of all,
Set Auto Postback property true for both Radio Button. and set Visible property False to both panel. also give Groupname Same to Both Radio Button.

then Double Click on First Radio Button.... So ,you get Method of Radio Button.
Inside it....

C#
If(RadioButton1.Checked)
{
   Panel.visible=true;
}
else
{
    Panel2.visible=false;
}


then Double Click on Second Radio Button.... So ,you get Method of Radio Button.
Inside it...

C#
If(RadioButton2.Checked)
{
   Panel1.visible=false;
}
else
{
    Panel2.visible=true;
}
 
Share this answer
 
v4
Personally I would use a radiobuttonlist. On the selectedIndexChanged event (onPostback) you could change the panel. What would work really well is if you used a mulitview control and for each view ActiveIndex you could select that based on the selectedIndex of the radiobuttonlist.
 
Share this answer
 
Comments
Arul R Ece 31-May-12 6:58am    
K Thanks friend...

I will try and let u know i have any issues

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900