Saturday, July 23, 2011

Remove html tags from string in Asp.net



  public static string StripHtml(string html, bool allowHarmlessTags)
    {
        if (html == null || html == string.Empty)
            return string.Empty;
        if (allowHarmlessTags)
        {
            return System.Text.RegularExpressions.Regex.Replace(html, "", string.Empty);
        }

        return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty);
    }

No comments:

Post a Comment

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...