手机
当前位置:查字典教程网 >编程开发 >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开发人员常犯的错误分析小结

asp.net WebForm页面间传值方法

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

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

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

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

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

net操作access数据库示例分享

asp.net图片上传实例

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

精品推荐
分类导航