我的页面里有个updatepanel,里面有两个按钮,用于给用户下载excel文件,结果今天上午搞了好一阵都是文件预备好了但执行下载没反应,后来才发现因为异步的原因下载操作需要另一个下载页面来做
有updatepanel的页面里
ScriptManager.RegisterStartupScript(this, this.GetType(), "RegisterStartupScript"
, String.Format("window.navigate('download.aspx?path={0}');", Server.UrlEncode(patch)), true);
在下载页面里
string path = Request.QueryString["path"];
ScriptManager.RegisterStartupScript(this, this.GetType(), "RegisterStartupScript", "window.close();", true);
本文介绍了解决ASP.NET中使用UpdatePanel组件时遇到的文件下载难题。通过使用ScriptManager注册StartupScript的方法来触发下载操作,并利用单独的下载页面完成文件下载流程。
473

被折叠的 条评论
为什么被折叠?



