📄 panel.aspx
字号:
<% @ Import Namespace="System.Drawing" %>
<Script Language="C#" Runat="Server">
public void Page_Load(Object src,EventArgs e)
{
if(Page.IsPostBack)
{
//如果不是第一次调用本页,则首先隐藏所有Panel
Panel1.Visible = false;
Panel2.Visible = false;
Panel3.Visible = false;
}
}
public void Selected(Object sender,EventArgs e)
{
Panel p = (Panel)FindControl(DropDown.SelectedItem.Text);
//将选中的Panel显示
p.Visible = true;
p.ForeColor=Color.Red;
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<b>Panel控件演示</b>
<hr>
<asp:Panel id="Panel1" runat="server"
Wrap="True"
>
<asp:Label id="lb1" Text="这是第一个Panel控件" Font-Bold="True" runat="server" />
</asp:Panel>
<hr>
<asp:Panel id="Panel2" runat="server"
Wrap="True"
>
<asp:Label Text="这是第二个Panel控件" Font-Bold="True" runat="server" />
</asp:Panel>
<hr>
<asp:Panel id="Panel3" runat="server"
Wrap="True"
>
<asp:Label Text="这是第三个Panel控件" Font-Bold="True" runat="server" />
</asp:Panel>
<hr>
请选择需要显示的Panel:<br>
<asp:DropDownList id="DropDown" AutoPostBack="True" OnSelectedIndexChanged="Selected" runat="server">
<asp:ListItem>Panel1</asp:ListItem>
<asp:ListItem>Panel2</asp:ListItem>
<asp:ListItem>Panel3</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -