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 name="str"></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;
}
{
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 name="str"></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;
}