Strange custom property behaviour (adding CDATA)

ve
ve
Vote:
 

Hi,

I've created a custom property which in edit mode has two textboxes. One which is used as a header, and the other one as HTML content.

It consists of two classes,

FooProperty, which inherits PropertyXhtmlString
FooPropertyControl, which inherits PropertyLongStringControl

When saving my data in the overridden ApplyEditChanges, I use a StringBuilder to create a basic xml layout for the data, like so,

<foo>
  <header>My Header</header>
  <content><![CDATA[ 

my html content

]]></content> </foo>

Later when I get the data for editing, my CDATA is now three (3) CDATA's, like so,

<![CDATA[<![CDATA[<![CDATA[<p>my html content</p>]]>]]>]]>
How come? When does this magic happen?
#37772
Mar 18, 2010 12:09
Vote:
 

Save something in the property, then check tbl_Property in the database.  Is the value correct here, or wrong as you note?  That would at least tell you if the problem is happening on save or retrieval.

Beyond that, I would switch to an XmlTextWriter to create the XML string.  I've used this quite a bit on custom properties and never had a problem with it (though, I was never writing any CDATA sections to my XML).

#38680
Apr 17, 2010 16:47
Vote:
 

If I were you I would inherit PropertyLongString rather than PropertyXhtmlString. The latter does a lot of processing on it's value that you probably don't need/want anyway, and might be responsible for garbling your data.

#38688
Apr 19, 2010 7:29