当前位置: 代码迷 >> ASP.NET >> 生成网页静态模板,该怎么处理
  详细解决方案

生成网页静态模板,该怎么处理

热度:4686   发布时间:2013-02-26 00:00:00.0
生成网页静态模板
请教如何生成网页静态模板?哪位高手可以给讲解一下

------解决方案--------------------------------------------------------
做成个模板,不变的地方写成html,内容的部分写成特殊字符.然后从数据库读取到内容后替换这些特殊字符如Replace( "$Name$ ",row[ "name "].ToString());
------解决方案--------------------------------------------------------
string FileName = @ "c:\ ";

string template = String.Empty;

using(StreamReader sr = new StreamReader(File.OpenRead(FileName + "test.htm "),System.Text.Encoding.GetEncoding( "gb2312 ")))
{
template = sr.ReadToEnd();
}

template = template.Replace( " <!--Replace--> ",GetData());

using(StreamWriter sw = new StreamWriter(FileName + "test ",false,System.Text.Encoding.GetEncoding( "gb2312 ")))
{
sw.WriteLine(template);
}
  相关解决方案