日期:2014-05-17  浏览次数:20452 次

请教在showModalDialog窗口中下载文件的问题
showModalDialog窗口中 <base target="_self" /> 这个加上了,点击下载文件时没有反应,因为以前的项目有很多是这样做的,前台的页面不能改,只能改所调用的下载的方法,下载貌似只能用repose的方法,能否在response中write一个方法,使其在showModalDialog窗口中能够直接下载呀,总的意思就是说前台的界面啊,调用的接口啊,都不能改了,只能改下载的方法,不知道能不能实现呀?
我调试了一下,好像在showModalDialog窗口中点击下载的话,Response.IsClientConnected=false,然后就不能继续了,请大哥大姐们帮忙解决一下啊!
------解决方案--------------------
帮你顶一下,

不太懂你的意思
------解决方案--------------------
帮顶下 、。友情Up
------解决方案--------------------
不可能,别想了...showModalDialog是阻塞方法,父页面的代码在子页面不关闭之前不能继续执行...
------解决方案--------------------
贴贴你下载的链接及下载的方法相关的代码
------解决方案--------------------
没做过下载方面的,不懂,帮顶了 也向小熊学习... 
但顺便提个问题   为什么下载要用到showModalDialog呢? 一般网站上面的下载都不是弹出模式框的啊~
------解决方案--------------------

public static class DownLoad
{
    public static void Down(string filepath)
    {
        System.IO.FileInfo file = new System.IO.FileInfo(filepath);
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Charset = "utf-8";
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
        HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
        HttpContext.Current.Response.ContentType = "application/octet-stream";
        HttpContext.Current.Response.WriteFile(file.FullName);
        HttpContext.Current.Response.End();
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.Clear();
    }


------解决方案--------------------
将弹出的模式框变frame,下载代码在frame对应的页面

------解决方案--------------------
帮顶吧~其实楼上有大牛已经说了
不过LZ到底想要什么样的 没明白