0

Update: I notice i receive

Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

This are the main parts of the code:

My main file header:

<%@ Register Src="~/UserControls/HostsControl.ascx" TagPrefix="hosts" TagName="HostsControl" %>

The hostControl Uses:

<%@ Register Src="~/UserControls/DataGridView.ascx" TagPrefix="dtbl" TagName="DataGridView" %>

In the datagridView i have an event:

<asp:ImageButton ID="imgExportToExcel" ImageUrl="~/images/files/excel.png" ToolTip="Export to excel" AlternateText="Excel" OnClick="ExportToExcel" runat="server" />

Now on the ExportToExel I have:

...create exel logic
FileInfo file = new FileInfo(filePath);
if (file.Exists)
{
    Response.ClearContent();
    Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
    Response.AddHeader("Content-Length", file.Length.ToString());
    Response.ContentType = "text/plain";
    Response.TransmitFile(file.FullName);
    Response.End();
}

The problem is the file isn't download. I think it because I use the Response from a Control

Please tell me if any information is missing

user3770158
  • 379
  • 1
  • 5
  • 16
  • 1
    Are you sure the click handler is hit at all? And content type for excel [is not text/plain](http://stackoverflow.com/questions/2937465/what-is-correct-content-type-for-excel-files) – Andrei Mar 25 '15 at 17:16
  • @Andrei The handler is hit, of course i debugged it. about the second part actually the ExportToExel is not as i posted. the file being downloaded is a test text file from my computer. it works when i put the response code in my Page_Load. The file path is not set to the excel it points to a txt file in my computer. sorry didnt mention that. – user3770158 Mar 26 '15 at 08:02

0 Answers0