When Response. Write is connected to Response. Redirect, Response. Write cannot be displayed and is directly transferred to the page of Response. Redirect.

Source: Internet
Author: User

Question 1:

When Response. Write is connected to Response. Redirect, Response. Write cannot be displayed and is directly transferred to the page of Response. Redirect.

Solution:

Response. Write ("<script succeed Ge = 'javascript '> alert ('Modified successfully'); window. location. href = 'index. aspx '</script> ");

If the script content contains variables, the solution is:

String a = the current record variable;

// Response. write ("<script language = 'javascript '> alert ('" + a + "modified successfully '); window. location. href = "/index. aspx '<";/script> ");

Response. write ("<script language = 'javascript '> alert ('" + a + "modified successfully '); window. location. href = '/index. aspx '</script> ");

Question 2:
To pass parameters in a connection, you can use the following methods:
String param = "passed parameters ";

Response. Write ("<script succeed Ge = 'javascript '> alert ('Modified successfully'); window. location. href = 'index. aspx? Par = "+ param +" '</script> ");

Question 3:
If an error occurs when Response. Redirect () or Response. Write () is used in the Ajax UpdatePanel button for URL-based page redirection.
Because Ajax is refreshing, You need to refresh the page when using Response to redirect with parameters. In UpdatePanel, set "ControlID" of "asp: PostBackTrigger" to the specified control name, for example:
<Triggers>
<Asp: PostBackTrigger ControlID = "GridView"/>
</Triggers>

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.