Because some parameters need to be passed between two pages in the project, the following methods are summarized:
Method 1:
Pass through URL link address
Send. aspx:
Protected void button#click (Object sender, eventargs E)
{
Request. Redirect ("default2.aspx? Username = honge ");
}
Receive. aspx:
String username = request. querystring ["username"]; To obtain the parameter value.
Method 2:
Send. aspx
<Form ID = "form1" runat = "server" Action = "receive. aspx" method = post>
<Div>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/>
<Asp: textbox id = "username" runat = "server"> </ASP: textbox>
</Div>
</Form>
Receive. aspx
String username = ruquest. Form ["receive"];
Method 3:
Send. aspx:
Protected void button#click (Object sender, eventargs E)
{
Session ["username"] = "honge ";
Request. Redirect ("default2.aspx ");
}
Receive. aspx:
String username = session ["username"]; To obtain the parameter value.
Method 4:
Send. aspx:
Protected void button#click (Object sender, eventargs E)
{
Application ["username"] = "honge ";
Request. Redirect ("default2.aspx ");
}
Receive. aspx:
String username = application ["username"]; To obtain the parameter value.
Method 5:
Send. aspx:
Public string name
{
Get {
Return "honge ";
}
}
Protected void button#click (Object sender, eventargs E)
{
Server. Transfer ("default2.aspx ");
}
Receive. aspx:
Send d = context. handler as send;
If (D! = NULL)
{
Response. Write (D. Name); to obtain the parameter value.
}
In Asp.net 2.0, you can use the following method:
previouspage d = context. handler as previouspage;
If (D! = NULL)
{< br> response. Write (D. Name); in this way, the parameter value is obtained.
}< br> it can also be used as follows:
send. aspx:
receive. aspx:
<% @ previouspagetype virtualpath = "~ /Default. aspx "%>
string name = previouspage. Name; the parameter value is obtained.