aspnet-404796-troubleshooting-grid-related-issues-pagerequestmanagerparsererrorexception.md
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.
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.
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 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()" .../>
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);
}
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
scriptManager.RegisterPostBackControl(ASPxButton1)
End Sub
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>