内存变量Session和Application传值
发送页后台CS代码:
protected void Button1_Click(object sender, EventArgs e) { Session["name"] = this.TextBox1.Text; //Application ["name"] = this.TextBox1.Text; Server.Transfer("WebForm1.aspx"); }
接收页后台CS代码:
protected void Page_Load(object sender, EventArgs e) { this.TextBox1.Text = (string)Session["name"]; //this.TextBox2.Text = (string)Application["name"]; }
Application 实质上是整个虚拟目录中所有文件的集合,如果想在整个应用范围内使用某个变量值,则Application对象是最佳选择。