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.

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

in gridview or datalist bind

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

Leave a Reply

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

You are commenting using your 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