1. Use the queryhttp://www.php.cn/wiki/57.html "target=" _blank "style=" LINE-HEIGHT:1.76EM; " >string variable
QueryString is a very simple method of transmitting values that can be displayed in the browser's address bar. You can use this method if you are passing one or more security requirements that are not high or have a simple structure. However, you cannot use this method for passing arrays or objects. Here is an example:
C # code for a.aspx
private void Button1_Click (object sender, System.EventArgs e) { string s_url; S_url = "B.aspx?name=" + Label1.Text; Response.Redirect (S_url);}
C # code in b.aspx
private void Page_Load (object sender, EventArgs e) { label2.text = request.querystring["name"];}
2. Using the Application object variable
The Application object is scoped to the whole global, which means it is valid for all users. Its common method is to use lock and unlock.
C # code for a.aspx
private void Button1_Click (object sender, System.EventArgs e) { application["name"] = Label1.Text; Server.Transfer ("b.aspx");}
C # code in b.aspx
private void Page_Load (object sender, EventArgs e) { string name; Application.Lock (); Name = application["Name"]. ToString (); Application.UnLock ();}
3. Use the session variable
Presumably this is the most common usage of everyone, its operation is similar to application, acting on the user's personal, so, excessive storage will lead to the depletion of server memory resources.
C # code for a.aspx
private void Button1_Click (object sender, System.EventArgs e) { session["name"] = Label.text;}
C # code in b.aspx
private void Page_Load (object sender, EventArgs e) { string name; Name = session["Name"]. ToString ();}
4. Using Cookie Object variables
This is also a common use of the method, as in the session, what it is for each user, but there is an essential difference, that is, the cookie is stored in the client, and the session is stored on the server side. And the use of cookies should be used in conjunction with the ASP.
C # code for a.aspx
private void Button1_Click (object sender, System.EventArgs e) { HttpCookie cookie_name = new HttpCookie ("name"); Cookie_name. Value = Label1.Text; Reponse.appendcookie (cookie_name); Server.Transfer ("b.aspx");}
C # code in b.aspx
private void Page_Load (object sender, EventArgs e) { string name; Name = request.cookie["Name"]. Value.tostring ();}
5. Using the Server.Transfer method
This can be said to be the method used by the development of the face-like object, which uses the Server.Transfer method to direct the process from the current page to another page, the new page uses the reply stream of the previous page, so this method is completely object-like, concise and effective.
C # code for a.aspx
public string name{ get{return label1.text;}} private void Button1_Click (object sender, System.EventArgs e) { Server.Transfer ("b.aspx");}
C # code in b.aspx
private void Page_Load (object sender, EventArgs e) { a newweb; Instance a form Newweb = (source) Context.Handler; string name; name = Newweb.name;}