【求助】 下载Word时的等待窗口? 无法触发js事件 。。。。

U2008 U2008 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

public partial class DownFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FileStream fileStream = new FileStream(Server.MapPath("readme.doc"), FileMode.Open);
long fileSize = fileStream.Length;

Response.ContentType = "application/octet-stream";
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode("readme.doc", System.Text.Encoding.UTF8) + "\"");
Response.AddHeader("Content-Length", fileSize.ToString());
byte[] fileBuffer = new byte[fileSize];
fileStream.Read(fileBuffer, 0, (int)fileSize);
fileStream.Close();
Response.Write(fileBuffer);
Response.End();
}
}



----------------------------以上是下载页面。



<TABLE runat=server border="0" id="processBarMask" bgcolor="#cccccc" style="VISIBILITY:hidden; POSITION: absolute" cellspacing="0" cellpadding="0">
<TR>
等待中。。。。。。。。。。。。。。
</TR>
</TABLE>





<SCRIPT language="javaScript">
var firstFlg = "0";

function processStart(){
with(document.all.processBarMask.style){
top = 0;
width = "100%";
height = "100%";
visibility = "visible";
}
document.all.processBarMask.focus();
}

function processEnd(){
document.all.processBarMask.style.visibility = "hidden";
}
</SCRIPT>



--------------------------------------------------------------------------------
下面有列表页中的一按钮,想执行一个文档转换,再提供下载,过程可能二三秒不定,看网络等多种因素。

protected void Button2_Click(object sender, EventArgs e)
{

// Response.Redirect("DownFile.aspx");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "js", "<script language='javascript'>processEnd()</script>");
processBarMask.Style.Add("display", "none");
processBarMask.Visible = false;

}

--------------------------------------------------------------------------------

在调用下载页输出文件流后,服务器端却无法触发关闭等待table , 这个需求如何设计呢??。。
...全文
评论 11
收藏 已收藏
分享
返回顶部
U2008
.NET社区 62,271 成员 668,968 内容