ASP.net download page

Posted by Russel on Stack Overflow See other posts from Stack Overflow or by Russel
Published on 2010-04-10T10:08:04Z Indexed on 2010/04/10 10:13 UTC
Read the original article Hit count: 416

Filed under:
|

Hi

I have a Reports.aspx ASP.NET page that allows users to download excel report files by clicking on several hyperlinks. When a report hyperlink is clicked, I open a new window using the javascript window.open method and navigate off to the download.aspx page. The code-behind for the download page creates a excel file on the fly using openxml(in memory) and send it back to the browser. Here is some code from the download.aspx page:

    byte[] outputFileBytes = CreateExcelReport().ToArray();
    Response.Clear();
    Response.BufferOutput = true;
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", "tempReport.xlsx"));
    Response.BinaryWrite(outputFileBytes);
    Response.Flush();
    Response.Close();
    Response.End();

My problem : Some of these reports take some time to generate. I would like to display a loading.gif file on my Reports.aspx page, while the download.aspx page is requested. Once the page request is completed, the loading.gif file should be made invisible.

Is there a way to achieve this. Perhaps some kind of event. I have mootools to my disposal.

Thanks

PS. I know that generating reports like this is not ideal, but thats a different story all together...

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript