手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >C#中HTML字符转换函数分享
C#中HTML字符转换函数分享
摘要:因此需要以下函数做转换:复制代码代码如下://////替换html中的特殊字符//////需要进行替换的文本。///替换完的文本。publi...

因此需要以下函数做转换:

复制代码 代码如下:

///<summary>

///替换html中的特殊字符

///</summary>

///<paramname="theString">需要进行替换的文本。</param>

///<returns>替换完的文本。</returns>

public static string HtmlEncode(string theString)

{

theString=theString.Replace(">",">");

theString=theString.Replace("<","<");

theString=theString.Replace(" ","");

theString=theString.Replace(""",""");

theString = theString.Replace("'", "");

theString=theString.Replace("n","<br/>");

return theString;

}

///<summary>

///恢复html中的特殊字符

///</summary>

///<paramname="theString">需要恢复的文本。</param>

///<returns>恢复好的文本。</returns>

public static string HtmlDiscode(string theString)

{

theString=theString.Replace(">",">");

theString=theString.Replace("<","<");

theString=theString.Replace(""," ");

theString=theString.Replace(""",""");

theString = theString.Replace("");

theString=theString.Replace("<br/>","n");

return theString;

}

【C#中HTML字符转换函数分享】相关文章:

asp.net图片上传实例

在asp.NET中字符串替换的五种方法第1/2页

.Net 2.0 原汁原味读取注册表

.net开发人员常犯的错误分析小结

asp.net WebForm页面间传值方法

C#中string与byte[]的转换帮助类-.NET教程,C#语言

Jmail发送邮件与带附件乱码解决办法分享

asp.net导出excel的简单方法

ASP.NET JSON字符串与实体类的互转换的示例代码

在ASP.Net中实现flv视频转换的代码

精品推荐
分类导航