Wednesday, June 23, 2010

Strip paragraph tags in umbraco properties using C#

Today I was pulling some properties from an umbraco document for use in a user control, and I found to my horror that some of the content still had starting and ending paragraph tags around it. This was of course thanks to the rich text editor,TinyMCE.
Normally, while using xslt one would write the following to remove them quickly.

<umbraco:item field='property' stripParagraph='true'
runat='server'>
Not finding an equivalent function in the umbraco API, i wrote this quick-and-dirty method that works quite well for the task(at least for me). Hope it saves some time for you.


2 comments:

  1. Hi Arviman,

    Great article - I'm having exactly the same issue. Whereabouts do you place this code to strip out the content though?

    Cheers,
    Tony

    ReplyDelete
  2. Wow, sorry for replying super late. You'd use this in the backend wherever you're pulling data using your Node or Document object.

    ReplyDelete