注册 登录
编程论坛 ASP.NET技术论坛

[求助]请教Panel的使用问题?

xinghun868 发布于 2007-09-20 15:52, 1859 次点击

private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
Panel1.Visible=true;
Panel2.Visible=false;
Panel3.Visible=false;
}
}

private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);

}

private void Button1_Click(object sender, System.EventArgs e)
{
Panel2.Visible=true;
Panel1.Visible=false;
}

private void Button2_Click(object sender, System.EventArgs e)
{
Panel3.Visible=true;
Panel2.Visible=false;
Label12.Text="你填写的资料为:"+"<br>"+
"用户名:"+TextBox2.Text+"<br>"+
"密码:"+TextBox1.Text+"<br>"+
"身份:"+DropDownList1.SelectedItem.Text+"<br>"+
"电话:"+TextBox3.Text+"<br>"+
"住址:"+TextBox4.Text+"<br>"+
"邮箱:"+TextBox5.Text+"<br>";
}


<%@ Page language="c#" Codebehind="zhucejiamian.aspx.cs" AutoEventWireup="false" Inherits="医院信息管理.zhucejiamian" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>zhucejiamian</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">&nbsp;
<asp:label id="Label2" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server"
Height="32px" Width="968px" BackColor="Lavender" Font-Size="X-Large">注册信息填写</asp:label><asp:label id="Label1" style="Z-INDEX: 102; LEFT: 0px; POSITION: absolute; TOP: 32px" runat="server"
Height="526px" Width="64px" BackColor="Lavender"></asp:label>
<asp:Panel id="Panel1" style="Z-INDEX: 103; LEFT: 160px; POSITION: absolute; TOP: 48px" runat="server"
Height="136px" Width="392px">
<asp:Label id="Label6" runat="server" Width="392px" Height="24px" BackColor="Gray">第一步:</asp:Label>
<asp:Label id="Label7" runat="server" Width="96px" Height="26px">用户名:</asp:Label>
<asp:TextBox id="TextBox2" runat="server" Width="192px" Height="32px"></asp:TextBox>
<BR>
<asp:Label id="Label3" runat="server" Width="96px" Height="26px">密码:</asp:Label>
<asp:TextBox id="TextBox1" runat="server" Width="192px" Height="32px"></asp:TextBox>
<BR>
<asp:Label id="Label4" runat="server" Width="96px" Height="24px">你的身份是:</asp:Label>
<asp:DropDownList id="DropDownList1" runat="server" Width="192px" Height="32px">
<asp:ListItem Value="管理员">管理员</asp:ListItem>
<asp:ListItem Value="医生">医生</asp:ListItem>
<asp:ListItem Value="病人">病人</asp:ListItem>
<asp:ListItem Value="领导">领导</asp:ListItem>
</asp:DropDownList>
</asp:Panel>
<asp:Button id="Button1" style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 208px" runat="server"
Width="104px" Height="32px" Text="下一步"></asp:Button>
<asp:Panel id="Panel2" style="Z-INDEX: 105; LEFT: 160px; POSITION: absolute; TOP: 256px" runat="server"
Width="376px" Height="160px">
<asp:Label id="Label5" runat="server" Width="400px" Height="32px" BackColor="Gray">第二步</asp:Label>
<asp:Label id="Label8" runat="server" Width="104px" Height="24px">电话:</asp:Label>
<asp:TextBox id="TextBox3" runat="server" Width="208px" Height="32px"></asp:TextBox>
<asp:Label id="Label9" runat="server" Width="104px" Height="32px">住址:</asp:Label>
<asp:TextBox id="TextBox4" runat="server" Width="209px" Height="32px"></asp:TextBox>
<asp:Label id="Label10" runat="server" Width="104px" Height="32px">邮箱:</asp:Label>
<asp:TextBox id="TextBox5" runat="server" Width="208px" Height="40px"></asp:TextBox>
</asp:Panel>
<asp:Button id="Button2" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 432px" runat="server"
Width="80px" Height="32px" Text="完成"></asp:Button>
<asp:Panel id="Panel3" style="Z-INDEX: 107; LEFT: 160px; POSITION: absolute; TOP: 480px" runat="server"
Width="400px" Height="104px">
<asp:Label id="Label11" runat="server" Width="400px" Height="28px" BackColor="Gray">恭喜你,注册成功!</asp:Label>
<asp:Label id="Label12" runat="server" Width="392px" Height="60px"></asp:Label>
</asp:Panel></FONT></form>
</body>
</HTML>


调试后Panel2,Panel3是隐藏了,但里面的那些控件还是没有隐藏啊
请问为什么我的不能实现啊???

10 回复
#2
jxnuwy042007-09-20 15:56
将控件放在Panel里就会随着Panel一起隐藏的.
#3
cyyu_ryh2007-09-20 15:58

不可能哦
是不是你没放进去哦

#4
xinghun8682007-09-20 16:04

我放进去了啊.可是不会一起隐藏啊

#5
jxnuwy042007-09-20 16:24
既然panel2,panel3没隐藏,那你怎么知道panel2,panel3隐藏了呢?
#6
jxnuwy042007-09-20 16:26
笔误
本意是:既然panel2,panel3里面的控件没隐藏,那你怎么知道panel2,panel3隐藏了呢?
#7
smoon2007-09-21 09:38
<asp:Panel id="Panel2" style="Z-INDEX: 105; LEFT: 160px; POSITION: absolute; TOP: 256px" runat="server"
Width="376px" Height="160px">
<asp:Label id="Label5" runat="server" Width="400px" Height="32px" BackColor="Gray">第二步</asp:Label>
<asp:Label id="Label8" runat="server" Width="104px" Height="24px">电话:</asp:Label>
<asp:TextBox id="TextBox3" runat="server" Width="208px" Height="32px"></asp:TextBox>
<asp:Label id="Label9" runat="server" Width="104px" Height="32px">住址:</asp:Label>
<asp:TextBox id="TextBox4" runat="server" Width="209px" Height="32px"></asp:TextBox>
<asp:Label id="Label10" runat="server" Width="104px" Height="32px">邮箱:</asp:Label>
<asp:TextBox id="TextBox5" runat="server" Width="208px" Height="40px"></asp:TextBox>
</asp:Panel>
<asp:Button id="Button2" style="Z-INDEX: 106; LEFT: 312px; POSITION: absolute; TOP: 432px" runat="server"
Width="80px" Height="32px" Text="完成"></asp:Button>
<asp:Panel id="Panel3" style="Z-INDEX: 107; LEFT: 160px; POSITION: absolute; TOP: 480px" runat="server"
Width="400px" Height="104px">
<asp:Label id="Label11" runat="server" Width="400px" Height="28px" BackColor="Gray">恭喜你,注册成功!</asp:Label>
<asp:Label id="Label12" runat="server" Width="392px" Height="60px"></asp:Label>
</asp:Panel>



加个背景在看看
#8
川流不息2007-09-21 19:38
建议楼主不要在HTML中这样直接在控件两头加panel,而是在页面中把控件拖到这个panel中,否则,有可能你在HTML中看到好像在Panel中了,但实际在页面里面却没有挂上钩。
#9
卡卡艾2007-09-23 08:32
以下是引用川流不息在2007-9-21 19:38:48的发言:
建议楼主不要在HTML中这样直接在控件两头加panel,而是在页面中把控件拖到这个panel中,否则,有可能你在HTML中看到好像在Panel中了,但实际在页面里面却没有挂上钩。

有道理.支持.
顶.
你得确定你的控件是在里面的.

#10
xinghun8682007-09-24 10:53
我是直接在页面中把控件拖到Panel中啊!!可是就是出现上面的问题啊
#11
bygg2007-09-24 11:01
从代码上看,是除了Button1和Button2没有放到Panel中,其它的都放到里面去了,但是你说的不能隐藏,我想看一下你关于隐藏的那段代码..
1