Quantcast
Viewing all articles
Browse latest Browse all 10

Visible Panels via RadioButtonList

This is a sample which shows how to, by choosing items in a RadioButtonList, you can show (make visible/invisible) only certain panels.

<script language="VB" Runat="server">
	Sub GetPanel(Source as Object, E as EventArgs)
		Select Case rb1.selectedItem.Value
			Case 1
				pnl1.visible=True
				pnl2.visible=False
				pnl3.visible=False
			Case 2
				pnl1.visible=False
				pnl2.visible=True
				pnl3.visible=False
			Case 3
				pnl1.visible=False
				pnl2.visible=False
				pnl3.visible=True
		End Select
	End Sub
</script>
<html>
	<head>
		<meta name="GENERATOR" Content="ASP Express 5.0">
		<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">
			This is panel 1
			</asp:panel>

			<asp:panel ID="pnl2" Runat="server" Visible="False">
			This is panel 2
			</asp:panel>

			<asp:panel ID="pnl3" Runat="server" Visible="False">
			this is panel 3
			</asp:panel>
		</form>
	</body>
</html>

Viewing all articles
Browse latest Browse all 10

Trending Articles