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

首頁 > 編程 > .NET > 正文

ASP.NET 生成靜態頁面 實現思路

2024-07-10 13:19:49
字體:
來源:轉載
供稿:網友
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代碼進行文件進行保存 平把路徑存如數據庫方便調用
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 怀化市| 浦县| 巴青县| 崇阳县| 九江县| 玉溪市| 行唐县| 太湖县| 乳山市| 塔城市| 武隆县| 观塘区| 连城县| 榆社县| 嘉义县| 琼海市| 会理县| 遂宁市| 无极县| 邹平县| 通榆县| 南昌县| 镇康县| 连南| 松阳县| 三穗县| 伊宁市| 伊宁县| 东光县| 莒南县| 宜城市| 江津市| 虎林市| 诏安县| 南溪县| 临清市| 汝州市| 清流县| 龙口市| 临清市| 云霄县|