欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET 生成靜態(tài)頁(yè)面 實(shí)現(xiàn)思路

 更新時(shí)間:2009年06月25日 13:32:44   作者:  
網(wǎng)上的cms系統(tǒng)好多都是支持生成靜態(tài)的,大家在使用過(guò)程中,也肯定遇到了很多的問(wèn)題,下面就是一些實(shí)現(xiàn)的原理,其實(shí) asp,php,asp.net的原理都是差不多的。
1.首頁(yè)選擇HTML原型網(wǎng)頁(yè)
然后再該HTML網(wǎng)頁(yè)添加一些自認(rèn)為特別的標(biāo)記,已便到時(shí)候靜態(tài)化的時(shí)候系統(tǒng)能更精確的進(jìn)行操作!
2.獲取HTML網(wǎng)頁(yè)代碼
我選擇的是通過(guò)FileUpload控件進(jìn)行獲取靜態(tài)度頁(yè)面模型,進(jìn)行保存!
復(fù)制代碼 代碼如下:

if (FileUpload1.PostedFile.FileName == "")
{
Response.Write("<script>alert('請(qǐng)確定您是否選擇了網(wǎng)頁(yè)')</script>");
return;
}
if ((FileUpload1.FileName.LastIndexOf(".") != "htm") || (FileUpload1.FileName.LastIndexOf(".") != "html"))
{
Response.Write("<script>alert('請(qǐng)確定您是否選擇了網(wǎng)頁(yè)')</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插入數(shù)據(jù)庫(kù) 已便使用時(shí)候提取!
sr.Close();
//貼上格式化HTML方法代碼

/// <summary>
/// 格式 化 HTML
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private string FormatStr(string str)
{
string strContent = str.Replace("<", "&lt;");
strContent = strContent.Replace(">", "&gt;");
//strContent = strContent.Replace(chr(13),"<br>");
strContent = strContent.Replace("\r", "<br>");
strContent = strContent.Replace(" ", "&nbsp;");
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.提取先前保存過(guò)的HTML頁(yè)面模型
然后通過(guò) string.Replace(char oldstring,char newstring );
對(duì)模型頁(yè)面中預(yù)先 設(shè)置好的特別標(biāo)記進(jìn)行替換成我們需要?jiǎng)討B(tài)更改的!
4.對(duì)動(dòng)態(tài)更新后的HTML代碼進(jìn)行文件進(jìn)行保存 平把路徑存如數(shù)據(jù)庫(kù)方便調(diào)用

相關(guān)文章

最新評(píng)論