Tuesday, 25 December 2012

Remove all HTML tag in c#


Suppose  label named lblDescription have html tags. We can remove all html tags as following.

Input Data: <p>Test</p>

Output Data:  Test  ( No <p> tag )

 lblDescription.Text="<p>Test</p>"
string result = Regex.Replace(lblDescription.Text, @"<(.|\n)*?>", string.Empty);
 lblDescription.Text  = result.Trim();

No comments:

Post a Comment