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:
Post.
send.aspxreceive.aspxstring username = Ruquest.Form["receive"]; |
Method 3:
Through session
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:
Use Application
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:
Use Server. Transfer
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. } |
If you can use this method in asp.net 2.0: PreviousPage
PreviousPage d = Context. Handler as PreviousPage;
If (d! = Null)
{
Response. Write (d. Name); to obtain the parameter value.
}
It can also be used as follows:
Send. aspx: receive. aspx: string name = PreviousPage. Name; in this way, the parameter value is obtained. |
If MasterPage is used in your page, Server. the PreviousPage passed by Transfer is invalid. I don't know why. so if MasterPage is used, it is best to use Session or Context. items ["username.
- 2 pages in total:
- Previous Page
- 1
- 2
- Next Page