This is a migrated thread and some comments may be shown as answers.

Ajaxified Export to CSV button (Using The response obj causes error in ajaxpanel)

1 Answer 94 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Sintayehu
Top achievements
Rank 1
Sintayehu asked on 04 Feb 2009, 06:47 PM
I have an export to csv button that worked untill I Ajaxified all controls on this page with an ajaxpanel.


I get a javascript error as follows:
[Exception... "'Sys.WebForms.PageRequestManagerParserErrorException: 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 '"Source","Source Cre'.'


My code resembles the one below:

Thanx for the help.

<asp:LinkButton ID="ExportLinkButton" runat="server" CssClass="export linkText menu left" Text="Export CSV"
OnClick="export_Clicked" ToolTip="Export to csv" ></asp:LinkButton>

protected void export_Clicked(object sender, EventArgs e)
        {
                   string fname= "path/FileName.csv";
                   string path = MapPath(fname);
                    string name = Path.GetFileName(path);
                    string ext = Path.GetExtension(path);
                    string type = "text/csv";
                    Response.ContentType = type;                  
                    Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                    Response.WriteFile(path);
                    Response.End();
            }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Feb 2009, 06:49 AM
Hi luay,

The exporting feature of the control work with regular postbacks only,
Here is the help article explaining how to export Ajaxified radgrid 

Export with AJAX enabled

Also here is the code library: Export RadGrid content to Excel/Word/CSV/PDF with Ajax enabled

-Shinu.
Tags
Ajax
Asked by
Sintayehu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or