Custom Blog Widget- Strip html from Blog Summary
Hello,
We have just started working with Sitefinity 4.2. And, I am trying to create a custom widget template for the list items. I followed the post by Radoslav and I was able to limit the content for a blog item to 20 words. I would like to strip all the html tags in the summary item that I display? Can you please provide me some suggestion on how can I strip all the html from the 20 words summary that I am displaying so that images or other styling is not displayed.
This is what I presently have to show the summary:
<
sitefinity:HtmlField
runat
=
"server"
DisplayMode
=
"Read"
Value='<%# SummaryParser.GetSummary(Eval("Content").ToString(),new SummarySettings(SummaryMode.Words,20,false,false)) %>' />
Any suggestions!!!
Hi San,
That's a tough one, currently we do not have a control that converts HTML into text. The closest to that functionality is our TextField control, however it will render the HTML tags as plain text.Alternatively you can create an external template and strip the HTML tags in your code, for example:
public
string
Strip(
string
text)
return
Regex.Replace(text, @”<(.|\n)*?>”,
string
.Empty);
Boyan,
Thank you for your response.
Regards,
San