Try our conversational search powered by Generative AI!

Creating custom property derived from EPiServer.Core.PropertyData

Hi, I'm new to Episerver. I just downloaded and installed Episerver 5. I need to create a custom property that contains several types of data. For example string, enumeration, and several integer fileds. I created a new custom property using the VS2005 toolbox controls. I saw that I have to implement ParseToObject and ParseToSelf which accept a string as a parameter. What is the format of this string? Is it a serialized object or what? I can't find any information about this in the documentation that came with the installation. Thanks in advance. Nikolay Raychev ProPeople
Dec 13, 2007 14:23
And somthing more... public override EPiServer.Core.PropertyDataType Type { get { // TODO: Write code that returns the PropertyDataType this property is based on. } } When I'm creating a custom property it seems that I must provide the base property type, which is an enumeration of the existing property types in Episerver. But the reason I'm deriving from EPiServer.Core.PropertyData is that I want to create completely new property type not derived from the existing ones. Where is the pint? Am I missing somthing? Nikolay Raychev ProPeople
Dec 13, 2007 16:25
Hi! EPiServer has a list of base types that you have to use to store property data. If you have a more complex type that you want to store I would use the longstring type and save the data as xml. It's possible that you can serialize a class as well but I havn't tried that myself.
Dec 13, 2007 17:31
Anyway, I made it using long string and used serialization to store my clas as XML. It works fine. But this issue remains... If I just want to make a property from scratch derived from EPiServer.Core.PropertyData why should I set EPiServer.Core.PropertyDataType that shows the base property type(one of the existing) when my new property type does not derive fron none of them?
Dec 21, 2007 15:51
Hi! Use PropertyDataType.LongString is you want to store it as xml (or String if it's shorter than 255 characters). This is used to define which column and type that should be used to save the value for the property.
Jan 07, 2008 13:59


I just wanted to add that i've managed to store a seializable class in a LongString property. Just in case anyone wondered if it would work :)

My code:

Public class yourObject

Functions to store and collect data:

public static string SerializeUsersForPage(List<yourObject> objectList)
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XmlSerializer seri = new XmlSerializer(typeof(List< yourObject >));
            seri.Serialize(sw, objectList);
            return sw.ToString() ?? string.Empty;

public static List< yourObject > GetUsersForPage(PageData page)
            if (page["yourPropName"] == null)return new List< yourObject >();
            string sb = page["yourPropName "] as string;
            if (string.IsNullOrEmpty(sb)) return new List< yourObject >();
            XmlSerializer s = new XmlSerializer( typeof(List< yourObject >) );
            List< yourObject > objectList =  (List< yourObject >)s.Deserialize(new StringReader(sb));
            return objectList ?? new List< yourObject >();

Oct 02, 2008 16:23
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.