鉴于大家对ASP.net十分关注,我们编辑小组在此为大家搜集整理了“Asp.net生成htm静态页面实现代码”一文,供大家参考学习!
2 public partial class _Default : System.Web.UI.Page
3 ...{
4 protected void Page_Load(object sender, EventArgs e)
5 ...{
6
7 }
8
9 //根据模板生成,保持在html文件夹中(部分源码搜集于网络)
10 protected void Button1_Click(object sender, EventArgs e)
11 ...{
12 //源码是替换掉模板中的特征字符
13
14 string mbPath =Server.MapPath("template.htm");
15 Encoding code = Encoding.GetEncoding("gb2312");
16 StreamReader sr = null;
17 StreamWriter sw = null;
18 string str = null;
19
20 //读取
21 try
22 ...{
23 sr = new StreamReader(mbPath, code);
24 str = sr.ReadToEnd();
25
26 }
27 catch (Exception ex)
28 ...{
29 throw ex;
30 }
31 finally
32 ...{
33 sr.Close();
34 }
本新闻共4页,当前在第1页 1 2 3 4