1, 发送页:
Application["sum"]=this.TextBox1.Text;
Server.Transfer("WebForm2.aspx");
Application["sum"]=this.TextBox1.Text;
Server.Transfer("WebForm2.aspx");
//用Server.Transfer不会转变网页地址栏,但网页已经转
接收页:
this.TextBox1.Text=(string)Application["sum"];
Application实质上是整个虚拟目录中所有文件的集合,如果想在整个应用范围内使用某个变量值,Application对象将是最佳的选择
this.TextBox1.Text=(string)Application["sum"];
Application实质上是整个虚拟目录中所有文件的集合,如果想在整个应用范围内使用某个变量值,Application对象将是最佳的选择
2, 发送页:
private void button_click(object sender,System.EventArgs e)
{
string url;
url="webform2.aspx?name="+TextBox1.Text ;
Response.Redirect(url);
}
接收页:
{
string url;
url="webform2.aspx?name="+TextBox1.Text ;
Response.Redirect(url);
}
接收页:
private void Page_Load(object sender,System.EventArgs e)
{
Label1.Text=Request.QueryString["name"];
}
//Querystring是一种非常简单的传值方式,其缺点就是会把要传送的值显示在浏览器的地址栏中
{
Label1.Text=Request.QueryString["name"];
}
//Querystring是一种非常简单的传值方式,其缺点就是会把要传送的值显示在浏览器的地址栏中
3, 发送页:
private void button_click(object sender,System.EventArgs e)
{
Session["Name"]=TextBox1.Text;
Response.Redirect("webform2.aspx");
}
接收页:
{
Session["Name"]=TextBox1.Text;
Response.Redirect("webform2.aspx");
}
接收页:
private void Page_Load(object sender,System.EventArgs e)
{
Label1.Text=Session["Name"].ToString();
}
{
Label1.Text=Session["Name"].ToString();
}