新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
淺談ASP.NET與HTML頁面關(guān)系
1.ASP.NET選擇HTML頁面

創(chuàng)新互聯(lián)主要從事做網(wǎng)站、成都做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)普陀,10多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575
然后再該HTML頁面添加一些自認為特別的標記,已便到時候靜態(tài)化的時候系統(tǒng)能更精確的進行操作!
2.ASP.NET獲取HTML頁面代碼
我選擇的是通過FileUpload控件進行獲取靜態(tài)度頁面模型,進行保存!
- if(FileUpload1.PostedFile.FileName=="")
- {
- Response.Write("alert('請確定您是否選擇了網(wǎng)頁')");
- return;
- }
- if((FileUpload1.FileName.LastIndexOf(".")!="htm")||
(FileUpload1.FileName.LastIndexOf(".")!="html"))- {
- Response.Write("alert('請確定您是否選擇了網(wǎng)頁')");
- return;
- }
- SystemSystem.Text.Encodingec=System.Text.Encoding.GetEncoding("gb2312");//指定編碼格式
- System.IO.StreamReadersr=newSystem.IO.StreamReader(FileUpload1.PostedFile.FileName,ec);
- stringstrHTML=Convert.ToString(sr.ReadToEnd());
- strHTML=FormatStr(strHTML);//格式化HTML代碼后,將此strHTML插入數(shù)據(jù)庫已便使用時候提??!
- sr.Close();
- //貼上格式化HTML方法代碼
- ///
- ///格式化HTML
- ///
- ///<paramnameparamname="str">
- ///
- privatestringFormatStr(stringstr)
- {
- strstringstrContent=str.Replace("<","<");
- strContentstrContent=strContent.Replace(">",">");
- //strContentstrContent=strContent.Replace(chr(13),"
");- strContentstrContent=strContent.Replace("\r","
");- strContentstrContent=strContent.Replace(""," ");
- strContentstrContent=strContent.Replace("[isOK]","<imgsrcimgsrc=");
- strContentstrContent=strContent.Replace("[b]","");
- strContentstrContent=strContent.Replace("[red]","<fontcolorfontcolor=CC0000>");
- strContentstrContent=strContent.Replace("[big]","<fontsizefontsize=7>");
- strContentstrContent=strContent.Replace("[/isOK]",">");
- strContentstrContent=strContent.Replace("[/b]","");
- strContentstrContent=strContent.Replace("[/red]","");
- strContentstrContent=strContent.Replace("[/big]","");
- returnstrContent;
- }
3.ASP.NET提取先前保存過的HTML頁面模型
然后通過string.Replace(char oldstring,char newstring );
對頁面模型中預先 設(shè)置好的特別標記進行替換成我們需要動態(tài)更改的!
4.對動態(tài)更新后的HTML代碼進行文件進行保存 平把路徑存如數(shù)據(jù)庫方便調(diào)用!
本文標題:淺談ASP.NET與HTML頁面關(guān)系
文章路徑:http://www.fisionsoft.com.cn/article/codpged.html


咨詢
建站咨詢
