我的应用程序中有一个导出按钮。当我单击该按钮时,它会回传到服务器并生成一个 Excel 文件。
我想在此过程中显示加载 gif,但是当打开/保存对话框显示时,我想隐藏 gif。
问题是我使用 Response.End 来显示文件打开/保存对话框。
有谁知道如何在 Response.End 之后调用客户端函数,或者有人有其他解决方案如何隐藏 gif 并让用户工作?
这是我的一段代码:
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!
}
谢谢你,因巴尔。