one, the current in the ASP.net page transfer value altogether has so several ways:
1. Form submission
<form action= "target.aspx" method = "POST" name = "Form1" >
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
Form1.submit ();
....
This kind of side in the ASP. NET is not valid because of ASP. NET form is always submitted to its own page, if you want to submit to another page, you need special treatment.
2, link address transmission
Receive page: string str = request["param1"]
3, session sharing
Send page: Session ("param1") = "1111";
Press Receive page String str = session ("param1"). ToString ();
4, Application sharing
Send page: Application ("param1") = "1111";
by page: string str = Application ("param1"). ToString ();
This method is not commonly used because application is shared across an application domain, and all users can change and set their values, so only use counters and so on where global variables are needed.
5. Cookies
6, Response.Redirect () way
Response.Redirect ("target.aspx?param1=1111¶m2=2222")
Receive page: string str = request["param1"]
7, Server.Transfer () way.
Server.Transfer ("target.aspx?param1=1111¶m2=2222")
Receive page: string str = request["param1"]
Two, if in two pages need a large number of parameters to pass transmission, such as data query, and other pages, with 1-6 of the method of transmission value and inconvenience, and the 7th method does have a unique advantage! However, this method requires a certain set of settings, now a brief description of how the method is used:
Take the query data page for example:
Set the following public properties (querypage.aspx) in the query page:
The following are the referenced contents: public class QueryPage:System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox txtstadate; protected System.Web.UI.WebControls.TextBox txtenddate; ... <summary> Start time </summary> public string Stadate { get{return this.txtStaDate.Text;} Set{this.txtstadate.text = value;} } <summary> End time </summary> public string EndDate { get{return this.txtEndDate.Text;} Set{this.txtenddate.text = value;} } .... private void Btnenter_click (object sender, System.EventArgs e) { Server.Transfer ("resultpage.aspx"); } } |
In the Show Query results page (resultpage.aspx):
The following are the referenced contents: public class ResultPage:System.Web.UI.Page { private void Page_Load (object sender, System.EventArgs e) {Convert to get the data entered in the previous page Querypage querypage = (querypage) Context.Handler; Response.Write ("Stadate:"); Response.Write (Querypage.stadate); Response.Write ("<br/>enddate:"); Response.Write (Querypage.enddate); } } |
Total 3 page: previous 1 [2] [3] Next page