I have an export button in my application. When I click the button, it posts back to the server and generates an Excel file.
I want to show a loading gif during the process, but when the open/save dialog shows, I want to hide the gif.
The problem is that I use Response.End to display the file open/save dialog.
Does anyone knows how can I call a client side function after Response.End, or anyone has another solution how can I hide the gif and let the user work?
here is a piece of my code:
protected void Page_Load(object sender, EventArgs e)
{
//starts the loading gif animation.
btnExport.Attributes.Add("onclick", "setTimeout(\"UpdateImg();\",300);");
}
protected void btnExport_Click(object sender, EventArgs e)
{
//generates the file
Response.ContentType = "application/vnd.openxmlformats- officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx");
Response.BinaryWrite(pck.GetAsByteArray());
Response.Flush();
//Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
//HERE I WANT TO STOP THE ANIMATION AND GO BACK TO THE PAGE!
}
Thank you, Inbal.