1 private string ToRead(System.Web.UI.Control ctl)
2 {
3 // HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Text01.txt");
4 HttpContext.Current.Response.Charset = "GB2312";
5 HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
6 //HttpContext.Current.Response.ContentType = "text/txt";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
7 ctl.Page.EnableViewState = false;
8 System.IO.StringWriter tw = new System.IO.StringWriter();
9 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
10 ctl.RenderControl(hw);
11 //Response.Write(tw.ToString());
12 return tw.ToString();
13
14 //HttpContext.Current.Response.Write(tw.ToString());
15 //HttpContext.Current.Response.End();
16 }
2 {
3 // HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Text01.txt");
4 HttpContext.Current.Response.Charset = "GB2312";
5 HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
6 //HttpContext.Current.Response.ContentType = "text/txt";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
7 ctl.Page.EnableViewState = false;
8 System.IO.StringWriter tw = new System.IO.StringWriter();
9 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
10 ctl.RenderControl(hw);
11 //Response.Write(tw.ToString());
12 return tw.ToString();
13
14 //HttpContext.Current.Response.Write(tw.ToString());
15 //HttpContext.Current.Response.End();
16 }