DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » Sys.WebForms.PageRequestManagerParserErrorException on PNG export button click

Sys.WebForms.PageRequestManagerParserErrorException on PNG export button click

Last revision: Aug 31, 2010

png export

You may get the following JavaScript error when clicking the Export button:

Microsoft JScript runtime error: 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 'PNG

The sample Export button fires the following code.

    protected void ButtonExport_Click(object sender, EventArgs e)
    {
        DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]);
        DayPilotMonth1.DataBind();

        Response.Clear();
        Response.ContentType = "image/png";
        Response.AddHeader("Content-Disposition", "attachment;filename=print.png");
        DayPilotMonth1.Export(ImageFormat.Png).WriteTo(Response.OutputStream);
        Response.End();
    }

It modifies the Response to return the PNG image instead of the page. That will not work if the button click is handled using partial PostBack.

In order to make the button work you need to handle the button click using a full page PostBack:

Related

How to open a new event dialog using TimeRangeSelected event (modal.js)
How to add a header to the exported calendar image (PNG)
How to save the exported PNG image to a file (without a web page)
How to record network activity using IE Developer Tools