用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

asp.net替换和恢复html特殊字符

时间:2015-01-29  来源:互联网  作者:佚名
/// <summary>
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</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>
/// 恢复html中的特殊字符
/// </summary>
/// <param name="theString">需要恢复的文本。</param>
/// <returns>恢复好的文本。</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 无限级分类实例代码 Asp.net 无限级分类实例代码在网上找了很久也没有找到例子,没办法了,想偷懒也偷不成了
asp.net SAF 中缓存服务的实现第1/5页 asp.net SAF 中缓存服务的实现第1/复制代码 代码如下:protectedvoidPage_Load(objectsender,Ev
相关文章
栏目更新
栏目热门