把要替换的内容用特殊符号试试   比如&neirong&

解决方案 »

  1.   

    是把HTM页面的内容用&这个符号吗?
      

  2.   

    str = str.Replace("showarticle",str); //这里有问题吧?
            str = str.Replace("biaoti",stringtext);
            str = str.Replace("neirong",strcontent);
      

  3.   

    现在内容可以插进去了!但是就是显示出2部分(标题和内容都显示2部分)...还有就是静态页面的title没有显示和标题一样的内容!!!       string path1 = Server.MapPath("news/");
            Encoding code = Encoding.GetEncoding("gb2312");
            string temp = Server.MapPath("news/text.htm");
            StreamReader sr = null;
            StreamWriter sw = null;
            string str = "";
            try
            {
                sr = new StreamReader(temp, code);
                str = sr.ReadToEnd();
            }
            catch (Exception exp)
            {
                Response.Write(exp.Message);
                sr.Close();
            }
            string htmlname = DateTime.Now.ToString("yyyymmddhhmmss") + ".htm";
            str = str.Replace("&showarticle&",str); 
            str = str.Replace("&biaoti&",stringtext);
            str = str.Replace("&neirong&",strcontent);
            try
            {
                sw = new StreamWriter(path1 + htmlname, false, code);
                sw.Write(str);
                sw.Flush();
                Response.Write("文件写入成功!");
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }
            finally
            {
                sw.Close();
            }
    静态页面的代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>&showarticle&</title>
    <style type="text/css">
    <!--
    body {
    margin-top: 0px;
    }
    -->
    </style></head>
    <body>
    <table width="800" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&biaoti&</td>
      </tr>
      <tr>
        <td>&neirong&</td>
      </tr>
    </table>
    </body>
    </html>
      

  4.   

    只要做一个动态的就行了。
    然后用WebClient生成静态文件