您的位置:首页 > 运维架构 > 网站架构

在网站中使用Session的简单例子

2010-06-23 17:32 281 查看
前台放两个Button 一个是提交,一个是查询

后台:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void LinkButton1_Click(object sender, EventArgs e)
{
string name = this.TextBox1.Text;

this.Session["Username"] =name;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
this.Label1.Text = this.Session["Username"] as string;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: