Yeah, that would strip out ALL html. Not sure if the OP intended this, but I just wanted to strip out the <p></p> the rich text editor seems to insist putting around any content. Was hoping there was a way to disable that behavior. In lieu of that, I just wrote a simple utility function:
public IHtmlString StripOuterParagraph(string content)
{
string newContent = content;
if (newContent.ToLower().StartsWith("<p>")) {
newContent = newContent.Substring(3);
}
if (newContent.ToLower().EndsWith("</p>")) {
newContent = newContent.Substring(0, newContent.Length - 4);
}
return new HtmlString(newContent);
}
Remove <p> tags in Umbraco 6
Hi
can any one help me on this
i have inserted Umbraco filed but it contains Html content with empty <p> tags
My Umbraco field .. How can Add removeparagraphtags for this field
@Umbraco.Field("pageTitle")
Thanks
Hi vijayadurga,
You could do it several ways, If you want to out the value in the a template you could do it like this:
<umbraco:Item field="pageTitle" stripParagraph="true" runat="server" />
If you will do it XSLT you can do it like this
In Razor you should could do it like this:
I hope this can help you.
/Dennis
The Razor syntax you show doesn't seem to help. The Umbraco rich text editor seems to put the paragraph tag in the field for you.
Oh my bad,
Have you tried use the library method StripHtml.
/Dennis
Yeah, that would strip out ALL html. Not sure if the OP intended this, but I just wanted to strip out the <p></p> the rich text editor seems to insist putting around any content. Was hoping there was a way to disable that behavior. In lieu of that, I just wrote a simple utility function:
Hi David,
You show be able to strip to strip specific tags also.
If you only wanted to strip specific tags, such as <p> tags, that should be able by doing this line of code:
/Dennis
Thanks Dennis, stripParagraph="true" works like a treat
Colin
is working on a reply...