Hi, I'm getting an "pagerequestmanagerparsererrorexception" error when trying to export a gridview to an excel spreadsheet within an updatepanel.
here is the code below ;
Protected Sub Export2Excel() Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=TestExcel.xls") Response.Charset = "" 'If you want the option to open the Excel file without saving than 'comment out the line below Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.ContentType = "application/vnd.xls" Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter() Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) Try Results_GridView.RenderControl(htmlWrite) Response.Write(stringWrite.ToString) Catch ex As Exception End Try Response.End() End SubAny help would be greatly appreciate..
Thanks,
Clint
You need to open up the excel in a pop up window or in an iframe. You can not send that content down through the Ajax Request and expect it to download on the users computer.
Eric
Hi Clint,
I think the simplest way is do not put the button inside any update panel.
Hope this helps.
Hi,
I am using a link button within the update panel, this is when I am getting the error.
Thanks
i could make it, adding an
<Triggers>
<asp:PostBackTrigger ControlID="ExportingButton" />
</Triggers>
to the updatepanel... hope this helps!!!
by!
Hi, the problem it's that when you use ajax you can't continue using theresponse.write,because the big idea of Ajax is not write all the page, only someparts, well the solution it's very easy, add an page and send StringWrite to a session variable, and add an Response.Redirect to the new page without ajax and in the load of the new page write your Response.write, and that's all, that will only open a windows in the client side asking if want to save or open the file, hope this be usefull fou U.
I've handled this in this post:
http://forums.asp.net/t/1047851.aspx
Hope it helps!
Bebandit
No comments:
Post a Comment