AJAX – Export to Excel / Word
If you are using Update Panel and try to Export gridview contents to EXCEL or Word, your asp.net page will throw nasty error. ”Sys.WebForms.PageRequestManagerParserErrorException”
Its because AJAX & Response.write don’t go together. By calling Response.Write() directly you are bypassing the normal rendering mechanism of ASP.NET controls. The bits you write are going straight out to the client without further processing (well, mostly…). This means that UpdatePanel can’t encode the data in its special format.
There are couple of ways to solve this problem.
1. Place the Export Button outside of Update Panel.
2. By Pass the Export Button using <Triggers>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID=”cmdExport” />
</Triggers>
</asp:UpdatePanel>
if your Export button is part of UserControl then specify usercontrolid:buttonid
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID=”uscSelCtl:cmdExport” />
</Triggers>
</asp:UpdatePanel>

[...] http://gchandra.wordpress.com/2008/01/08/ajax-export-to-excel-word-syswebformspagerequestmanagerpars... Posted in Uncategorized. [...]
ASP.Net AJAX - Export to Excel/Word « Life at work with .Net
February 11, 2008 at 8:38 am
Thank you, just what i was looking for!
petka
May 1, 2008 at 5:59 pm
“usercontrolid:buttonid” Elegant
Nice =)…. thankss
Pablogrind
May 12, 2008 at 11:50 pm
what if the user control is dynamically defined in the code behind? in the aspx page i have a placeholder. how would i access that user control button from within the update panel? is there a way to do this?
vk
July 15, 2008 at 9:09 am
Thanks so much. You help me slove my problem. ^^
chuti
October 8, 2008 at 3:56 am
When i use Export Button outside the update panel then i got this error
The Controls collection cannot be modified because the control contains code blocks (i.e. ).
and when i use trigger then i got this error
A control with ID ‘UpdatePanel1:ddl_ExportGrid’ could not be found for the trigger in UpdatePanel ‘UpdatePanel1′
I have UpdatePanel having id UpdatePanel1 that contains grid view and in grid i have a dropdown list having id ddl_ExportGrid.
Please help….!
Adeel Fakhar
May 2, 2009 at 4:43 am
Thx so much
I search for a long time about this problem
AkE
July 21, 2009 at 4:59 am
Excellent stuff, I searched for this one and left it, and now I found it.
Thanks so much chandra
Ram
August 13, 2009 at 11:30 am