生成网页静态模板
请教如何生成网页静态模板?哪位高手可以给讲解一下
[解决办法]
做成个模板,不变的地方写成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.html ",false,System.Text.Encoding.GetEncoding( "gb2312 ")))
{
sw.WriteLine(template);
}