protected override void Render(HtmlTextWriter writer)
{
//把最终要输出的html压缩后再输出
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
base.Render(tw);
string outhtml = html.ToString();
outhtml = Regex.Replace(outhtml, "\\s+", " ");
outhtml = Regex.Replace(outhtml, ">\\s+<", "><");
outhtml = outhtml.Trim();
writer.Write(outhtml);
}
protected override void Render(HtmlTextWriter writer)
{
//最终输出前先存为html文件,如果发布最新信息了,可以打开一次default.aspx,然后他又会生成一次html
//这是默认的Render实现,直接输出到writer中
//base.Render(writer);
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
//通过base.Render()方法,把生成的HTML写入到我们定义的tw中
base.Render(tw);
string path = Server.MapPath("index.html");
StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default);
//写入到文件中
sw.Write(html.ToString());
sw.Close();
//写入到writer中,以输出页面的HTML
//注意,这里不能再调用base.Render(writer),会出现错误
writer.Write(html.ToString());
}
{
//把最终要输出的html压缩后再输出
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
base.Render(tw);
string outhtml = html.ToString();
outhtml = Regex.Replace(outhtml, "\\s+", " ");
outhtml = Regex.Replace(outhtml, ">\\s+<", "><");
outhtml = outhtml.Trim();
writer.Write(outhtml);
}
protected override void Render(HtmlTextWriter writer)
{
//最终输出前先存为html文件,如果发布最新信息了,可以打开一次default.aspx,然后他又会生成一次html
//这是默认的Render实现,直接输出到writer中
//base.Render(writer);
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
//通过base.Render()方法,把生成的HTML写入到我们定义的tw中
base.Render(tw);
string path = Server.MapPath("index.html");
StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default);
//写入到文件中
sw.Write(html.ToString());
sw.Close();
//写入到writer中,以输出页面的HTML
//注意,这里不能再调用base.Render(writer),会出现错误
writer.Write(html.ToString());
}
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“asp.net实例代码protected override void Render(HtmlTextWriter writer)”评论...