清除HTML中的特殊字符

   /// <summary>
        /// 清楚HTML中的特殊字符
        /// </summary>
        /// <param name="Htmlstring"></param>
        /// <returns></returns>
        public static string DelHTML(string Htmlstring)
        {
            if (string.IsNullOrEmpty(Htmlstring))
                return "";
            //特殊的字符
            Htmlstring = Htmlstring.Replace("&", "");
            Htmlstring = Htmlstring.Replace("<", "");
            Htmlstring = Htmlstring.Replace(">", "");
            Htmlstring = Htmlstring.Replace("*", "");
            Htmlstring = Htmlstring.Replace("-", "");
            Htmlstring = Htmlstring.Replace("?", "");
            Htmlstring = Htmlstring.Replace(",", "");
            Htmlstring = Htmlstring.Replace("/", "");
            Htmlstring = Htmlstring.Replace(";", "");
            Htmlstring = Htmlstring.Replace("*/", "");
            Htmlstring = Htmlstring.Replace("\r\n", "");
            Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();

            return Htmlstring;
        }

posted @ 2013-08-12 17:18  永不言败,自信相伴  阅读(484)  评论(0编辑  收藏  举报