SYS. webforms. pagerequestmanagerparsererrorexception: unable to analyze messages received from the server

Source: Internet
Author: User

When I used updatepannel today, I found that a javascript error is always prompted when I clicked the button to trigger the event. At first I thought it was a JS problem. Later I commented it out, and I still asked this prompt, baidu once found this article and solved my problem. Now I am posting it for your reference.

Chinese:

SYS. webforms. pagerequestmanagerparsererrorexception:

The common cause of this error is that the response filter, httpmodules, or server tracing will be enabled when response. Write () is called to modify the response.

Details: An error occurred while analyzing the "output content" nearby.

 

The solution is as follows:

1. if you call response. the server control of the write () method adds a <triggers> node under updatepanel to the page where updatepanel is used. You can use postbacktrigger to register and modify the control. The Code is as follows:

1. <asp: scriptmanager id = "scriptmanager1" runat = "server">
2. </ASP: scriptmanager>
3. <asp: updatepanel id = "updatepanel1" runat = "server">
4. <triggers>
5. <asp: postbacktrigger controlid = "button2"/> <! -- Button2 is the following button ID that needs to use response. Write () in the button2_click event -->
6. </triggers>
7. <contenttemplate>
8. <asp: button id = "button2" runat = "server" onclick = "button2_click" text = "button"/>
9. <asp: updateprogress id = "updateprogress1" runat = "server">
10. <progresstemplate> </progresstemplate>
11. </ASP: updateprogress>
12. </contenttemplate>
13. </ASP: updatepanel>

2. However, if you use updatepanel on the master page, you cannot solve the problem by using the preceding method. Otherwise, the following error may occur:

A control with ID 'btnexport' could not be found for the trigger in updatepanel 'updatepanel1 '.

This is because the control registered in <asp: postbacktrigger controlid = "btnexport"/> cannot be found in updatepanel1, because we generally did not add this control (btnexport) to the master page ). (Of course, if you add a control with the ID of btnexport to the <contenttemplate> node of updatepanel, no error will occur .)

What should I do if such an error occurs? My solution is to add the following code in the page_load event of the page where the control using the response. Write () method is located:
(Scriptmanager) master. findcontrol ("scriptmanager1"). registerpostbackcontrol (btnexport );

// Scriptmanager1 is the ID of <asp: scriptmanager id = "scriptmanager1" runat = "server"> </ASP: scriptmanager>

Address: http://www.cnblogs.com/shenyixin/archive/2012/03/08/2385376.html

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.