//将HTTP头添加到输出流
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.Panel1.Visible =true;
//将服务器控件中的内容输出到ystem.Web.UI.HtmlTextWriter对象中
this.Panel1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.Panel1.Visible =true;
//将服务器控件中的内容输出到ystem.Web.UI.HtmlTextWriter对象中
this.Panel1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货