求助啊~~用 response.write 导出word时 不弹出下载文件对话框 为什么呢??

时间:2022-05-04 14:48:34
代码是放在 page_load里最后一行  页面加载完后 直接将页面导出word 没弹出保存对话框 感觉好像是程序终止了

7 个解决方案

#1


问题补充  就在IE里不好使 不管是ie6还是7  其它工具都正常(遨游/腾讯的tt浏览器)

#2


代码拿出来看看

#3


dm

#4


代码 很普通啊  page_load 就不用了吧 反填页面而已 最后调下面的公共方法
public static void ExprtWord(HttpResponse Response, Control c,string filename)
        {
            System.IO.StringWriter SW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            c.EnableViewState = false;
            c.RenderControl(HTW);
            Response.Buffer = true;
            Response.ContentType = "application/ms-winword";
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".doc");
            Response.Write(SW.ToString());
            Response.Flush();
            Response.End();
        }

#5


晕  下沉的好快  小顶一下

#6


帮帮忙啦~~~

#7


Response.ContentType = "application/msword";
 

#1


问题补充  就在IE里不好使 不管是ie6还是7  其它工具都正常(遨游/腾讯的tt浏览器)

#2


代码拿出来看看

#3


dm

#4


代码 很普通啊  page_load 就不用了吧 反填页面而已 最后调下面的公共方法
public static void ExprtWord(HttpResponse Response, Control c,string filename)
        {
            System.IO.StringWriter SW = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
            c.EnableViewState = false;
            c.RenderControl(HTW);
            Response.Buffer = true;
            Response.ContentType = "application/ms-winword";
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".doc");
            Response.Write(SW.ToString());
            Response.Flush();
            Response.End();
        }

#5


晕  下沉的好快  小顶一下

#6


帮帮忙啦~~~

#7


Response.ContentType = "application/msword";