日期:2014-05-20  浏览次数:20411 次

asp.net用户登陆小问题!!!!!!!!!!!
首页有2个Panle,Panle1用户登陆,Panle2是用户登陆完显示的状态,首页登陆完后显示Panle2的状态,登陆用户名用Session获取,然后随便点个别的连接在返回首页,为什么仍然需要登陆,而不是Panel2的状态


------解决方案--------------------
不回有问题的 我测试过了
lz你看看是不是你的Session时间设置的过短啊

我写的代码你测试看看
Default3.aspx页面
<body>
<form id= "form1 " runat= "server ">
<asp:Panel ID= "Panel1 " runat= "server " Height= "110px " Width= "181px ">
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "登陆 " /> </asp:Panel>
<br />
<asp:Panel ID= "Panel2 " runat= "server " Height= "50px " Width= "125px " Visible= "False ">
<asp:Label ID= "Label1 " runat= "server "> </asp:Label> </asp:Panel>
<br />
<a href= "default4.aspx "> default4 </a>
</form>
</body>
Default3.aspx后台代码
protected void Page_Load(object sender, EventArgs e)
{
if (Session[ "txt "] == null)
{
Panel1.Visible = true;
Panel2.Visible = false;
}
else
{
Panel1.Visible = false;
Panel2.Visible = true;
Label1.Text = Session[ "txt "].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Session[ "txt "] = Label1.Text = TextBox1.Text.Trim();
Panel1.Visible = false;
Panel2.Visible = true;
}
Default4.aspx页面
<body>
<form id= "form1 " runat= "server ">
<a href= "Default3.aspx "> default3 </a>
</form>
</body>