Clarify the problems of asp.net page Jump and page value passing

Source: Internet
Author: User

Although this is a basic thing, it is still very messy. So today I have made a little effort to organize it. What I want to bring to you is the page Jump problem.

The following are four ways to open a new page.

1. Go directly to the new page. The original page is not retained.

Response. Redirect ("Webform6.aspx? Id = 1 ");

2. Go directly to the new page. The original page is not retained.

NServer. Transfer ("Webform6.aspx? Id = 1 ", true );

3. Open the new page and keep the original page, but both pages can be operated.

NResponse. Write ("<script> window. open ('webform6. aspx? Id = 1', '_ blank', ''); </script> ");

4. Open the new page and keep the original page, but only the child page can be operated. The parent page can be operated only when the child page is closed. Next is the issue of passing values between different pages.

1. Server. Transfer can only jump to the page specified by the local virtual directory, while Response. Redirect can jump to the page specified by other virtual directories, which is very flexible;

2. Server. Transfer can easily pass the page parameters to the specified page. Use a status such:

Server. Transfer ("WebForm2.aspx", True ),
The existing request string and all the variables in the Form will be kept and submitted to your target page. The passed value can only be read when the PAGELOAD function comes in for the first time.

For example, WebForm1.aspx has a text box named TextBox1, which is passed to WebForm2.aspx using preserveForm to True,

Send: Server. Transfer ("Webform6.aspx", true );

Receive: TextBox7.Text = Request. Form ["TextBox1"];

3. When Server. Transfer jumps to another page during use, the address displayed by the browser will not change, and sometimes it will lead to misunderstanding. Of course, this effect is also required in some occasions;

4. Server. Transfer can reduce client requests to the Server

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.