| 1.首页选择HTML原型网页 然后再该HTML网页添加一些自认为特别的标记,已便到时候静态化的时候系统能更精确的进行操作!
 2.获取HTML网页代码
 我选择的是通过FileUpload控件进行获取静态度页面模型,进行保存!
 
 复制代码 代码如下: if (FileUpload1.PostedFile.FileName == "")
 {
 Response.Write("<script>alert('请确定您是否选择了网页')</script>");
 return;
 }
 if ((FileUpload1.FileName.LastIndexOf(".") != "htm") || (FileUpload1.FileName.LastIndexOf(".") != "html"))
 {
 Response.Write("<script>alert('请确定您是否选择了网页')</script>");
 return;
 }
 System.Text.Encoding ec = System.Text.Encoding.GetEncoding("gb2312");//指定编码格式
 System.IO.StreamReader sr = new System.IO.StreamReader(FileUpload1.PostedFile.FileName, ec);
 
 string strHTML =Convert.ToString(sr.ReadToEnd());
 strHTML=FormatStr(strHTML); //格式化HTML代码后,将此strHTML插入数据库 已便使用时候提取!
 sr.Close();
 //贴上格式化HTML方法代码
 
 /// <summary>
 /// 格式 化 HTML
 /// </summary>
 /// <param></param>
 /// <returns></returns>
 private string FormatStr(string str)
 {
 string strContent = str.Replace("<", "<");
 strContent = strContent.Replace(">", ">");
 //strContent = strContent.Replace(chr(13),"<br>");
 strContent = strContent.Replace("r", "<br>");
 strContent = strContent.Replace(" ", " ");
 strContent = strContent.Replace("[isOK]", "<img src=");
 strContent = strContent.Replace("[b]", "<b>");
 strContent = strContent.Replace("[red]", "<font color=CC0000>");
 strContent = strContent.Replace("[big]", "<font size=7>");
 strContent = strContent.Replace("[/isOK]", "></img>");
 strContent = strContent.Replace("[/b]", "</b>");
 strContent = strContent.Replace("[/red]", "</font>");
 strContent = strContent.Replace("[/big]", "</font>");
 return strContent;
 }
 
 3.提取先前保存过的HTML页面模型
 然后通过 string.Replace(char oldstring,char newstring );
 对模型页面中预先 设置好的特别标记进行替换成我们需要动态更改的!
 4.对动态更新后的HTML代码进行文件进行保存 平把路径存如数据库方便调用
 (编辑:宣城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |