Webform_ cross-page pass-through values

Source: Internet
Author: User

Asp. NET provides us with three ways, one can pass the corresponding value by using QueryString , another is to pass the corresponding value through the session variable, and also through Server.Transfer method to implement.

Using QueryString
QueryString is a very simple way of passing values, and the disadvantage is that the value to be transferred is displayed in the address bar of the browser, and the object cannot be passed in this method. This approach is best if you want to pass a security that is not so important or a simple value.
1. Create a Web Form
2. Place a button1 in the new Web form, placing two Textbox1,textbox2
3. Create Click events for button buttons.

The code is as follows:
private void Button_Click (Object Sender,system.eventargs e)
{
string URL;
Url= "webform2.aspx?name=" +textbox1.text + "&am email=" +textbox2.text;
Response.Redirect (URL);
}
4. Create a new target page named WebForm2
5. Place two Label1,label2 in WebForm2
Add the following code to the WebForm2 Page_Load:
private void Page_Load (Object Sender,system.eventargs e)
{
label1.text=request.querystring["name"];
label2.text=request.querystring["Email"];
}

 Response-Response Request Object

Response.Redirect (path); -redirect

Response.Write ("AAAA"); -Output content

Server.Transfer (path);

Request-Get requested object request["key"-Return by default is string type

Webform_ cross-page pass-through values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.