Web登录状态管理及界面切换示例
// 设置登录状态及登录名
bool loginStatus = false;
string strLoginName = "";
protected void Page_Load(object sender, EventArgs e) {
if (!loginStatus) {
this.Panel2.Visible = false;
this.Panel1.Visible = true;
this.Label1.Text = "当前的时间是:" + DateTime.Now.ToLongDateString();
} else {
this.Panel2.Visible = false;
this.Panel1.Visible = false;
this.Label1.Text += ";欢迎您," + strLoginName;
}
}
protected void LinkButton1_Click(object sender, EventArgs e) {
this.Panel2.Visible = true;
this.Panel1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e) {
loginStatus = true;
this.Panel2.Visible = false;
this.Panel1.Visible = false;
strLoginName = this.TextBox1.Text;
this.Label1.Text += ";欢迎您," + strLoginName;
}
文件大小:967KB
评论区