国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

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

2020-01-18 01:13:24
字體:
供稿:網(wǎng)友
1.首頁選擇HTML原型網(wǎng)頁
然后再該HTML網(wǎng)頁添加一些自認為特別的標記,已便到時候靜態(tài)化的時候系統(tǒng)能更精確的進行操作!
2.獲取HTML網(wǎng)頁代碼
我選擇的是通過FileUpload控件進行獲取靜態(tài)度頁面模型,進行保存!
復制代碼 代碼如下:

if (FileUpload1.PostedFile.FileName == "")
{
Response.Write("<script>alert('請確定您是否選擇了網(wǎng)頁')</script>");
return;
}
if ((FileUpload1.FileName.LastIndexOf(".") != "htm") || (FileUpload1.FileName.LastIndexOf(".") != "html"))
{
Response.Write("<script>alert('請確定您是否選擇了網(wǎng)頁')</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ù)庫 已便使用時候提取!
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;
}

3.提取先前保存過的HTML頁面模型
然后通過 string.Replace(char oldstring,char newstring );
對模型頁面中預先 設置好的特別標記進行替換成我們需要動態(tài)更改的!
4.對動態(tài)更新后的HTML代碼進行文件進行保存 平把路徑存如數(shù)據(jù)庫方便調(diào)用
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 天全县| 阳东县| 东乡族自治县| 和平区| 冷水江市| 沧源| 苍梧县| 清涧县| 平昌县| 桃园县| 峨边| 大同市| 珲春市| 营山县| 巴南区| 合江县| 耒阳市| 汶上县| 阿拉善左旗| 涿鹿县| 海南省| 金溪县| 阳泉市| 常山县| 盱眙县| 嘉禾县| 泗水县| 惠东县| 五家渠市| 溧阳市| 江都市| 无极县| 遂昌县| 漳浦县| 虎林市| 民和| 伽师县| 兴宁市| 荆门市| 洛川县| 贡嘎县|