HTML Entities

Image

Advertisements

Remove HTML tags

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);
}

You want to remove HTML tags from your string.

1
2
3
4
string html = "remover <b>html</b> tages " +
     "from <i>string</i> asp.net c#";
string newString = Regex.Replace(html , "<.*?>", string.Empty);

in gridview or datalist bind

?
1
<%#  Regex.Replace(Eval("ItemDetail").ToString(), "<.*?>", string.Empty)%>