Summary of common methods for passing ASP. NET page values

Source: Internet
Author: User

1. Form submission:
Copy codeThe Code is as follows:
<Formaction = "target. aspx" method = "post" name = "form1">
<Input name = "param1" value = "1"/>
<Input name = "param2" value = "2"/>
</Form>
....
Form1.submit ();
....

This method is generally used in html pages and not in asp.net, because asp.net forms are always submitted to their own pages.

Ii. Link Method of tag
Copy codeThe Code is as follows:
<Ahref = "target. aspx? Param1 = 1 & param2 = 2 "> link transfer </A>
Receiving page: string str = Request ["param1"]

Iii. Session sharing
Copy codeThe Code is as follows:
Sending page: Session ("param1") = "1 ";
String str = Session ("param1"). ToString ();

4. Application Sharing
Copy codeThe Code is as follows:
Sending page: Application ("param1") = "1 ";
By page: string str = Application ("param1"). ToString ();

This method is not often used. Because the Application is shared within an Application domain, all users can change and set its value. Therefore, only the counters and other places that require global variables are used.

5. Cookie

6. Response. Redirect () method
Copy codeThe Code is as follows:
Response. Redirect ("target. aspx? Param1 = 1 & param2 = 2 ")
Receiving page: stringstr = Request ["param1"]

VII. Server. Transfer () Mode
Copy codeThe Code is as follows:
Server. Transfer ("target. aspx? Param1 = 1 & param2 = 2 ")
Receiving page: stringstr = Request ["param1"]

Related Article

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.