将你要输出的内容放在asp:panel标签内,

 

StringWriter tw =new StringWriter(); HtmlTextWriter hw =new HtmlTextWriter(tw); this.pan_content.RenderControl(hw); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); response.ContentType ="application/vnd.ms-word"; response.AddHeader("Content-Disposition", "attachment; filename="+ Server.UrlPathEncode(Server.UrlDecode(this.lbtitle.Text) +".doc")); //response.Charset = "utf-8"; response.Write(tw.ToString()); response.End();
posted on 2012-09-10 10:44  Black Bean  阅读(218)  评论(0编辑  收藏  举报