Render方法生成静态页
//请参考下面的例子
void Page_Load(){
Response.Charset="";
this.EnableViewState =false;
StringWriter tw=new StringWriter();
HtmlTextWriter wt =new HtmlTextWriter(tw);
string path=@"c:\test.htm";
//FileInfo info =new FileInfo(@"c:\test.txt");
StreamWriter wter = File.CreateText(path);
//输出所有信息
this.RenderControl(wt);
wter.Write(tw.ToString());
//Response.Write(tw.ToString());
wter.Close();
wt.Close();
tw.Close();
Response.End();
//生成相应文件,然后定向到该文件
Response.Redirect(path);
}
void Page_Load(){
Response.Charset="";
this.EnableViewState =false;
StringWriter tw=new StringWriter();
HtmlTextWriter wt =new HtmlTextWriter(tw);
string path=@"c:\test.htm";
//FileInfo info =new FileInfo(@"c:\test.txt");
StreamWriter wter = File.CreateText(path);
//输出所有信息
this.RenderControl(wt);
wter.Write(tw.ToString());
//Response.Write(tw.ToString());
wter.Close();
wt.Close();
tw.Close();
Response.End();
//生成相应文件,然后定向到该文件
Response.Redirect(path);
}
申明
非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!
博文欢迎转载,但请给出原文连接。