ASP.NET自动生成HTML
try
…{
string path = HttpContext.Current.Server.MapPath(“”);
string temp = HttpContext.Current.Server.MapPath(“HTMLPage.htm“);
Encoding code = Encoding.GetEncoding(“gb2312“);
StreamReader sr = null;
StreamWriter sw = null;
string str = “”;
sr = new StreamReader(temp, code);
str = sr.ReadToEnd();
string htmlfilename = DateTime.Now.ToString(“yyyyMMddHHmmss“) + “.html“;
string strText = “测试test <input type=’button’ value=’123123′></input>“; //这段文本是汉字和英文还有html按钮 通过替换[biaoti]成为新的HTML内容
str = str.Replace(“[biaoti]“, strText);
sw = new StreamWriter(path+htmlfilename, false, code);
sw.Write(str);
sw.Flush();
}
catch
…{
Response.Write(“出错“);
}