我有一些下载文件的例程代码(如下所示)。但是,在处理此文件时(下载文件的请求和保存对话框之间存在滞后时间),我想添加某种JavaScript模式警报,让用户知道挂起的操作。我怎样才能通过用户控件轻松完成此操作?
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + zipFileName + ";");
response.TransmitFile(zipFilePath);
response.Flush();
response.End();
答案 0 :(得分:2)
可能最好先显示javascript警告,然后只需将浏览器重定向到下载网址,不是吗?
有些事情:
function alertAndDownload() {
if (!confirm("You are about to be redirected to a file download. This may take a while! Is that ok?")) return;
window.location = "http://yoursite.com/goDownloadTheirThing.aspx";
}