日期:2014-05-17 浏览次数:20380 次
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();
------解决方案--------------------
加一个方法:
public override void VerifyRenderingInServerForm(Control control) { //base.VerifyRenderingInServerForm(control); }