手机
当前位置:查字典教程网 >编程开发 >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字符转换函数分享】相关文章:

net操作access数据库示例分享

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

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

ASP.Net中表单POST到其他页面的方法分享

asp.net中MD5 16位和32位加密函数

asp.net导出excel的简单方法

asp.net图片上传实例

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

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

上传图片后使用数据库保存图片的示例分享

精品推荐
分类导航