|
‘ Code Behind: Protected SubGetPanel(Source as Object, E asEventArgs) Select Caserb1.selectedItem.Value Case1 pnl1.visible=True pnl2.visible=False pnl3.visible=False Case2 pnl1.visible=False pnl2.visible=True pnl3.visible=False Case3 pnl1.visible=False pnl2.visible=False pnl3.visible=True End Select End Sub
‘ ASPX page: <html> <head> <title>RadioButtonList - Panels</title> </head> <body> <form id="form1" Runat="server"> <asp:RadioButtonList ID="rb1" Runat="Server" OnSelectedIndexChanged="GetPanel" AutoPostBack="True"> <asp:ListItem Value="1">Panel 1</asp:ListItem> <asp:ListItem Value="2">Panel 2</asp:ListItem> <asp:ListItem Value="3">Panel 3</asp:ListItem> </asp:RadioButtonList> <asp:panel ID="pnl1" Runat="server" Visible="False" BackColor="Yellow"> This is panel 1 </asp:panel>
<asp:panel ID="pnl2" Runat="server" Visible="False" BackColor="LightBlue"> This is panel 2 </asp:panel>
<asp:panel ID="pnl3" Runat="server" Visible="False" BackColor="LightGreen">
this is panel 3 </asp:panel> </form> </body> </html>
|