Last post Jun 24, 2019 08:15 AM by venkatzeus
Jun 19, 2019 04:22 AM|venkatzeus|LINK
I am using VS 2010, C# and ASP.NET Web Application.
The excel is not created. I have used the below code:
DataSet ds = getDataSetExportToExcel(con);
using (XLWorkbook wb = new XLWorkbook())
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())
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:UpdatePanel ID="upd1" runat="server">
How to fix this?
Jun 19, 2019 06:37 AM|Brando ZWZ|LINK
According to your description, I couldn't understand your quesiton clearly.
Do you mean you call the webmethod in the code-behind through the page method and get the PageRequestManagerParserErrorException?
Could you please post more details codes about your webmethod and details aspx page for us to reproduce the issue?
If you could post more details information, it will be more easily for us to reproduce the issue and find out the solution.
Jun 19, 2019 06:45 AM|venkatzeus|LINK
Thanks for the reply. I am trying to export dataset to Excel. In my aspx page, I have used script manager. I am using VS 2010, C# , ASP.NET Web application.
The code gets the data from the dataset and passes to memory stream and when the line hits the response.end , I am getting this error
Jun 20, 2019 01:39 AM|Brando ZWZ|LINK
Thank you for explaining your codes again.
Could you please tell when you run the export excel codes? In a button click event or Scriptpagemanager pagemethod?
Is this button is inside the updatepanel?
Jun 20, 2019 11:34 AM|venkatzeus|LINK
Thanks for the reply.
Button click event calls the Export functionality and the button is inside the update panel
Jun 20, 2019 12:36 PM|jzero|LINK
Seems you posted just a piece of code and all code, with code provided i'm not sure if it works, it drive me think MemoryStream ast end will be empty.
Anyway, supposing it works, you can make Scripts to run Before and After Async Postback, check thi link
There is also ScriptManager.AsyncPostBackError Event
With scripts in place, on your browser using F12 you can also set a breakpoint on endhandler to inspect values.
If possible, refactor you code to have it inside a Try/Catch block, so you can grab exceptions before return data to browser
Jun 24, 2019 08:15 AM|venkatzeus|LINK
Thanks for the reply. I used the below line in page load and it is working:
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);