弹出模态对话框后,在模态对话框内下载文件失败
我在页面A.aspx中有一个按钮,点击时处理:
string sURL = "<script type='text/javascript'>window.showModalDialog('B.aspx',window,'');</script>";
Response.Write(sURL);
然后在模态对话框B.aspx中有一个LinkButton,点击时,如果直接在按钮事件中处理文件下载,则根本不会弹出下载框,下载的代码如下:
string sFilePath = Server.MapPath("File\\123.txt") ;
System.IO.FileInfo file = new System.IO.FileInfo(sFilePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "utf-8";
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.WriteFile(file.FullName);
Response.Flush();
Response.End();
下载的代码在非模态对话框中测试通过。
我再尝试点击LinkButton,打开C.aspx页面,在C页面中处理下载代码,结果还是弹出来晃一下就没了,偶尔会弹出下载对话框,但是文件名却是C.aspx,打开C页面的代码如下:
Response.Write("<script type='text/javascript'>window.open('C.aspx?FileName=" + Path.GetFileName(sFilePath) + "');</script>");
在网上找了很久,都没有找到合适的解决方法,所以到这里来咨询,希望得到高手的回答,谢谢。
string sURL = "<script type='text/javascript'>window.showModalDialog('B.aspx',window,'');</script>";
Response.Write(sURL);
然后在模态对话框B.aspx中有一个LinkButton,点击时,如果直接在按钮事件中处理文件下载,则根本不会弹出下载框,下载的代码如下:
string sFilePath = Server.MapPath("File\\123.txt") ;
System.IO.FileInfo file = new System.IO.FileInfo(sFilePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "utf-8";
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.WriteFile(file.FullName);
Response.Flush();
Response.End();
下载的代码在非模态对话框中测试通过。
我再尝试点击LinkButton,打开C.aspx页面,在C页面中处理下载代码,结果还是弹出来晃一下就没了,偶尔会弹出下载对话框,但是文件名却是C.aspx,打开C页面的代码如下:
Response.Write("<script type='text/javascript'>window.open('C.aspx?FileName=" + Path.GetFileName(sFilePath) + "');</script>");
在网上找了很久,都没有找到合适的解决方法,所以到这里来咨询,希望得到高手的回答,谢谢。
...全文
相关推荐
Jsp页面使用jquery ui制作弹出层的详细方法
NULL 博文链接:https://dbh0512.iteye.com/blog/1607850
【08】MFC入门到精通——MFC模态对话框 和 非模态对话框 解析 及 实例演示
本文介绍了MFC中模态对话框和非模态对话框的创建与显示方法。模态对话框(如加法计算器)弹出时会阻止其他窗口交互,使用DoModal()函数显示;非模态对话框则允许同时操作其他窗口,需通过指针动态创建(new)并调用Create()和ShowWindow()显示。以加法计算器为例,详细演示了如何添加提示对话框模板、关联类、修改按钮事件逻辑,并对比了两种对话框的特性差异。关键点包括:模态对话框的返回值处理、非模态对话框的指针初始化及资源释放。代码示例和工程下载链接提供了实践参考。
网页实现图片和PDF文件预览
网页通过jQuery实现点击在弹出窗口中预览图片、预览PDF文件。
flavr 下载
这个一个扁平化的对话框,提示框效果。 拥有多种弹出效果,符合各种对话框需求。 这个对话框,你值得拥有。
jQuery多种类型自定义对话框插件jDialog源码.zip
jQuery多种类型自定义对话框插件jDialog源码.zip


