asp.net page transfer values commonly used methods Summary _ Practical skills

Source: Internet
Author: User

First, form submission:

Copy Code code as follows:

<formaction= "target.aspx" method = "POST" name = "Form1" >
<input name = "param1" value = "1"/>
<input name = "param2" value = "2"/>
</form>
....
Form1.submit ();
....

This approach is typically used in HTML pages, not in asp.net, because asp.net forms are always submitted to their own pages.

Two, a label link way
Copy Code code as follows:

<ahref= "target.aspx?param1=1&param2=2" > Link address transfer </A>
Receive page: string str = request["param1"]

third, session sharing
Copy Code code as follows:

Send page: Session ("param1") = "1";
Press receive page string str =session ("param1"). ToString ();

four, application sharing
Copy Code code as follows:

Send page: Application ("param1") = "1";
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.

Five, Cookies

six, Response.Redirect () way
Copy Code code as follows:

Response.Redirect ("target.aspx?param1=1&param2=2")
Receive page: Stringstr = request["param1"]

Seven, Server.Transfer () way
Copy Code code as follows:

Server.Transfer ("target.aspx?param1=1&param2=2")
Receive page: Stringstr = request["param1"]

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.