HI.
I am using VS 2010, C# and ASP.NET Web Application.
I am trying to export dataset to excel. I am getting an error as - JavaScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
The excel is not created. I have used the below code:
DataSet ds = getDataSetExportToExcel(con);
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(ds);
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename= " + filename1 + ".xlsx");
using (MemoryStream MyMemoryStream = new MemoryStream())
{
wb.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}
The error is at line - Response.End()
I have the scriptmanager added in the page with the below code:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" AsyncPostBackTimeout="360000"></asp:ScriptManager><asp:UpdatePanel ID="upd1" runat="server"><ContentTemplate>
How to fix this?
Thanks