Im trying to truncate the article text to display only the first 100 characters of the string.
@item.Value("articleContent").ToString().Truncate(100) <a href="@item.Url">Read More..</a>
This works perfectly to truncate the string - but it displays the <p>
tag at the begining.
This is what it looks like -
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In aliquet sapien non posuere pretium... Read More..
How can I avoid displaying the HTML Tags?
Just strip the HTML tags before the truncate
Regex.Replace(item.Value("articleContent"), @"<[^>]*>", String.Empty).Truncate(100);