asp.net替換和恢復(fù)html特殊字符
更新時(shí)間:2008年05月10日 21:41:29 作者:
替換html中的特殊字符需要進(jìn)行替換的文本。替換完的文本。
/// <summary>
/// 替換html中的特殊字符
/// </summary>
/// <param name="theString">需要進(jìn)行替換的文本。</param>
/// <returns>替換完的文本。</returns>
public string HtmlEncode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" ", " ");
theString=theString.Replace(" ", " ");
theString=theString.Replace("\"", """);
theString=theString.Replace("\'", "'");
theString=theString.Replace("\n", "<br/> ");
return theString;
}
/// <summary>
/// 恢復(fù)html中的特殊字符
/// </summary>
/// <param name="theString">需要恢復(fù)的文本。</param>
/// <returns>恢復(fù)好的文本。</returns>
public string HtmlDiscode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" "," ");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","\"");
theString=theString.Replace("'","\'");
theString=theString.Replace("<br/> ","\n");
return theString;
}
/// 替換html中的特殊字符
/// </summary>
/// <param name="theString">需要進(jìn)行替換的文本。</param>
/// <returns>替換完的文本。</returns>
public string HtmlEncode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" ", " ");
theString=theString.Replace(" ", " ");
theString=theString.Replace("\"", """);
theString=theString.Replace("\'", "'");
theString=theString.Replace("\n", "<br/> ");
return theString;
}
/// <summary>
/// 恢復(fù)html中的特殊字符
/// </summary>
/// <param name="theString">需要恢復(fù)的文本。</param>
/// <returns>恢復(fù)好的文本。</returns>
public string HtmlDiscode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" "," ");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","\"");
theString=theString.Replace("'","\'");
theString=theString.Replace("<br/> ","\n");
return theString;
}
您可能感興趣的文章:
- ASP.NET對(duì)HTML頁面元素進(jìn)行權(quán)限控制(一)
- ASP.NET對(duì)HTML頁面元素進(jìn)行權(quán)限控制(二)
- ASP.NET對(duì)HTML頁面元素進(jìn)行權(quán)限控制(三)
- Asp.net動(dòng)態(tài)生成html頁面的方法分享
- Asp.net 動(dòng)態(tài)加載用戶自定義控件,并轉(zhuǎn)換成HTML代碼
- asp.net(C#) 動(dòng)態(tài)添加非ASP的標(biāo)準(zhǔn)html控件(如添加Script標(biāo)簽)
- 利用ASP.NET技術(shù)動(dòng)態(tài)生成HTML頁面
- asp.net 圖片驗(yàn)證碼的HtmlHelper
- ASP.NET 頁面刷新的實(shí)現(xiàn)方法(包括html,js)
- asp.net HTML文件上傳標(biāo)簽
- asp.net下URL網(wǎng)址重寫成.html格式、RSS、OPML的知識(shí)總結(jié)
- asp.net正則表達(dá)式刪除指定的HTML標(biāo)簽的代碼
- ASP.NET動(dòng)態(tài)增加HTML元素的方法實(shí)例小結(jié)
相關(guān)文章
使用Spring.Net框架實(shí)現(xiàn)多數(shù)據(jù)庫
這篇文章介紹了Spring.Net框架實(shí)現(xiàn)多數(shù)據(jù)庫的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-03-03
ASP.NET XmlHttp跨域訪問實(shí)現(xiàn)代碼
最近項(xiàng)目需要實(shí)現(xiàn)XmlHttp的POST方法到另一服務(wù)器上的頁面進(jìn)行數(shù)據(jù)的更新,可是IE會(huì)提出“該頁正在訪問其控制范圍之外的信息,是否繼續(xù)?”等警告信息,而在其他瀏覽器上直接禁止掉,GOOGLE一下原來是XmlHttp的跨域訪問問題,找了很多資料,說是提供很多解決方案,可是都沒有用處。2008-11-11
.NET命令行解析器示例程序(命令行選項(xiàng)功能)
經(jīng)常需要開發(fā)一下小工具,之前都是自己解析命令行參數(shù),接觸過動(dòng)態(tài)語言社區(qū)以后,發(fā)現(xiàn)命令行解析有特定的模式和框架可以利用,本文介紹一個(gè).NET 平臺(tái)的類庫CommandLineParser2013-11-11
Asp.Net 網(wǎng)站性能優(yōu)化之緩字決 (上) 緩沖寫數(shù)據(jù)
通常情況下Asp.Net 網(wǎng)站的底層數(shù)據(jù)存儲(chǔ)都是關(guān)系數(shù)據(jù)庫,關(guān)系數(shù)據(jù)庫資源比較昂貴,而且也很容易造成瓶頸。緩字決文章就是為大家介紹如何有效使用緩存,異步寫緩沖數(shù)據(jù)庫的壓力,從而保證網(wǎng)站的性能。2010-06-06
.NET微信小程序用戶數(shù)據(jù)的簽名驗(yàn)證和解密代碼
這篇文章主要介紹了.NET微信小程序用戶數(shù)據(jù)的簽名驗(yàn)證和解密代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12
Asp.Net Core 通過中間件防止圖片盜鏈的實(shí)例
本篇文章主要介紹了Asp.Net Core 通過中間件防止圖片盜鏈的實(shí)例,具有一定的參考價(jià)值,有興趣的可以了解一下。2016-12-12
.Net Core 使用NLog記錄日志到文件和數(shù)據(jù)庫的操作方法
這篇文章主要介紹了.Net Core 使用NLog記錄日志到文件和數(shù)據(jù)庫的操作方法,本文分步驟通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-07-07

