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, <a href= "target.aspx?param1=1111¶m2=2222" > Link address transfer </A>
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:
In the query page, set the following public properties (querypage.aspx): Common 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"); Note: Use resultpage.aspx to receive passed parameters.
}
}
In the Show Query results page (resultpage.aspx):
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; Note: referencing the page handle
Response.Write ("Stadate:");
Response.Write (Querypage.stadate);
Response.Write ("<br/>enddate:");
Response.Write (Querypage.enddate);
}
}
Third, if there are many query pages to share a result Page Setup method:
In this way the key lies in "querypage querypage = (querypage) context.handler;" conversion, which can be achieved only if the transformation is not dependent on a particular page.
If you want all query pages to inherit an interface, define a method in the interface, the only function of this method is to let the results page to obtain the parameters required to build the results, you can achieve multiple pages sharing a result page operation!
1, first define a class, use this class to place all query parameters: (*.cs)/**////<summary>
The value to be used in the resulting page
</summary>
public class Queryparams
{
private string stadate;
private string EndDate;
/**//**//**////<summary>
Start time
</summary>
public string Stadate
{
get{return this.stadate;}
Set{this.stadate = value;}
}
/**//**//**////<summary>
End time
</summary>
public string EndDate
{
get{return this.enddate;}
Set{this.enddate = value;}
}
}
2. Interface Definition:
/**////<summary>
Define the query interface.
</summary>
public interface Iqueryparams
{
/**//**//**////<summary>
Parameters
</summary>
Queryparams Parameters{get;}
}
3, Query page Inheritance Iqueryparams interface (querypage.aspx):
/**////<summary>
Query page, inherit interface
</summary>
public class QueryPage:System.Web.UI.Page, Iqueryparams
{
protected System.Web.UI.WebControls.TextBox txtstadate;
protected System.Web.UI.WebControls.TextBox txtenddate;
Private Queryparams Queryparams;
/**//**//**////<summary>
The parameters used by the resulting page
</summary>
Public Queryparams Parameters
{
Get
{
return queryparams;
}
}
private void Btnenter_click (object sender, System.EventArgs e)
{
assigning values
Queryparams = new Queryparams ();
Queryparams.stadate = This.txtStaDate.Text;
Queryparams.enddate = This.txtEndDate.Text
Server.Transfer ("resultpage.aspx");
}
}
4, the other outside of the page is also set
Current 1/2 page
12 Next read the full text