手机
当前位置:查字典教程网 >编程开发 >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其他页面如何调用Web用户控件写的分页

asp.net使用jquery模板引擎jtemplates呈现表格

asp.net对URL含有中文参数的转换

检测含有中文字符串的实际长度

net操作access数据库示例分享

log4net配置和使用方法分享

Asp.net(C#)文件操作函数大全

asp.net导出excel的简单方法

asp.net图片上传实例

ASP.NET编程精选25种函数源程序

精品推荐
分类导航