We have a Sharepoint solution that uses AJAX. The button that triggers this is inside an update panel.
One of the things that we do is generate a MS Word document, that is then opened on the client so that it can be printed.
The code that sends the document to the client looks like this:
void OpenFileInWord(byte[] data)
{
Response.Clear();
Response.AddHeader("Content-Type", "application/msword");
Response.BinaryWrite(data);
Response.Flush();
Response.End();
}
The error that we are getting is:
Message: 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.
Details: Error parsing near '<?mso-application pr'.
We could save the document in Sharepoint first, and then open it from Sharepoint, but we would prefer not to do this.
If you have the button inside updatepanel this maybe causing this, if don´t want to move it, just add a trigger for the button on the updatepanel, a postback trigger.
The action that causes this code to execute MUST be a postback event, and not an AJAX call.
This is due to the nature of the way AJAX requests are processed.
Keep your button outside the update panel. Then it works fine.
Set your button to cause full postback like this:
<Triggers>
<asp:PostBackTrigger ControlID="PrintButton" />
</Triggers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With