Solution to the error of using Response.Write output JavaScript script in Ajax __ajax

Source: Internet
Author: User

Using the AJAX Web Forms in vs 2008 to develop the ASP.net program, you want to do a close window, as follows:
protected void Btndelete_click (object sender, EventArgs e)
{
int NID = convert.toint16 (request.querystring["ID"]);

Deleteweatherservices (NID);

Response.Write ("<script language=javascript>window.opener=null;self.close" (this); </script> ");
}
If you put the Btndelete button outside the UpdatePanel, you can normally close the window.
If you put the Btndelete button inside the UpdatePanel, you cannot close the window and prompt for an error:
Sys.WebForms.PageRequestManagerParserErrorException: Unable to parse the message received from the server. The common reason for an error occurs when you are calling
Response.Write () When the response is modified, the response filter, HttpModule, or server trace is enabled.
More information: An error occurred while parsing the "<script Language=jav" for the attachment

Workaround:

Scriptmanager.registerstartupscript (this. Updatepanel1,typeof (UpdatePanel), "CloseWindow", "<script language=javascript>window.opener=null;self.close (this); </script> ", false);

The true of that argument is that it automatically adds the mark "<script>" and "</script>"
False is to manually go to this tag yourself

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.