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)%>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s