ASP.NET中页面传值
<一>
在接收页 的html代码里加上一行: <%@ Reference Page = "WebForm1.aspx" %>
WebForm1 webForm=(WebForm1)Context.Handler;
this.TextBox1.Text=webForm.name;
<二>
在发送页
Server.Transfer("WebForm1.aspx?name=张三");
接收页
this.TextBox1.Text=Request["sum"].ToString();
or this.TextBox1.Text=Request.Params["sum"].ToString();
this.TextBox1.Text=Request.QueryString["sum"];
<三>
发送页:
Application["name"]=this.TextBox1.Text;
Server.Transfer("WebForm1.aspx");
接收页:
this.TextBox1.Text=(string)Application["name"];
Session用户法和Application的用法类似
<四>
发送页:
1.定义静态变量: public static string str="";
2. str=this.TextBox1.Text;
Response.Redirect("webform1.aspx");
接收页:
1.引入第一页的命名空间:using WebApplication1;
2 this.TextBox1.Text=WebForm1.str;
浙公网安备 33010602011771号