1

I want to add a modalpopup or a wait loader while the file is being generated and as soon as it downloads, I want to hide the popup. This is just to lock the screen so that there is no interference while the file is being generated and the response in the means of a file is downloaded.

I have an aspx button in my html which 'onclick' runs some huge lines of code to generate excelPackage file.

<div> 
    <asp:Button ID="Button1" runat="server" Text="Download" onclick="Button1_Click"/>
</div>

Here is a snippet of the function Button1_Click():

ExcelPackage excel = new ExcelPackage();
var file = get_file();
//long code which writes the content of file to excel taking time
using (var memoryStream = new MemoryStream())
{
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;  filename=file.xlsx");
    excel.SaveAs(memoryStream);
    memoryStream.WriteTo(Response.OutputStream);
    Response.Flush();
    Response.End();
}
Ankan Kumar Giri
  • 243
  • 1
  • 3
  • 12

0 Answers0