1. QueryString
This is the simplest way to pass a value, but the disadvantage is that the value of the pass is displayed in the browser's address bar and cannot be passed on to the object, only for simple delivery and low security requirements.
Delivery: location.href= "webform2.aspx?name=" + yourname&&name2= "+ yourName2;
Receive: String name = request.querystring["Name"];
2. Form
Delivery: Based on the name and value of the control in the form, such as:
<form id= "Form1" method= "POST" >
<input type= "text" name= "name" value= "xxx"/>
</form>
The form needs to be submitted <input type= "Submit"/> or document.getElementById ("Form1"). Submit ();
Receive: String name = request.form["Name"];
3. Session
It is important to note that storing too much data in the session variable consumes more server resources, and some cleanup actions should be used to remove unwanted sessions when using the session.
Removal: Session.remove ("name");
Delivery: session["name"] = YourName;
Receive: String name=session["name"]. ToString ();
4. Cookies
Delivery: HttpCookie cookie_name = new HttpCookie ("name");
Cookie_name. Value = YourName;
Response.appendcookie (Cookie_name);
Receive: request.cookies["name"]. Value;
5. Application
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.
Pass: application["name"] = name;
Reception: Application.Lock ();
String name = application["Name"]. ToString ();
Application.UnLock ();
Lock is designed to prevent multi-threaded tampering, ensuring that the moment
6. Server.Transfer
Passed:
WebForm1 write the attributes that need to be passed to the value such as:
public string Name {get{return txtname.text;}}
Execution Server.Transfer ("webform2.aspx");
Receive:
Receive parameters in WebForm2:
WebForm1 wf1= (WebForm1) Context.Handler;
Response.Write (WF1. Name);
Several ways to transfer values between. NET pages