Skip to main content
All docs
V23.2

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed

  • 2 minutes to read

Error Description

If a component that supports data export (specifically ASPxGridView, ASPxCardView, ASPxVerticalGrid, or ASPxTreeList) is placed inside the UpdatePanel container, the component’s Export{format}ToResponse method call causes the following exception:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Explanation

When a component inside UpdatePanel initiates a postback, the panel performs an asynchronous post, adds a custom HTTP header to sent data, and processes the server response on the client side.

When an Export{format}ToResponse method is called, the export engine changes the Response and sends it to the client. On the client, the UpdatePanel cannot encode received data and throws the exception.

Solution

To solve the issue, make a component send a postback and update the entire page (not only the UpdatePanel component) when exporting data. The following techniques are available:

Move a Trigger Control Outside UpdatePanel

Move a control that triggers export outside the UpdatePanel component and use the control in the standard postback mode.

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">  
    <ContentTemplate>
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" ... />
    </ContentTemplate>  
</asp:UpdatePanel>  
<dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxGridView1.ExportXlsToResponse()" .../>

Register a Postback Control Inside UpdatePanel (Programmatically)

Call the RegisterPostBackControl method to register a control inside an UpdatePanel control as a trigger for a postback.

<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">  
    <ContentTemplate>
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" ... />
        <dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxGridView1.ExportXlsToResponse()" ... />
    </ContentTemplate>  
</asp:UpdatePanel>  
protected void Page_Init(object sender, EventArgs e) {  
    ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
    scriptManager.RegisterPostBackControl(ASPxButton1);  
}  

Register a Postback Control Inside UpdatePanel (Declaratively)

Mark the control as a PostBackTrigger for an UpdatePanel control.

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">  
    <ContentTemplate>
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" ... />
        <dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxGridView1.ExportXlsToResponse()" .../>
    </ContentTemplate>  
    <Triggers>  
        <asp:PostBackTrigger ControlID="ASPxButton1" />  
    </Triggers>  
</asp:UpdatePanel>