Custom properties broken?


Custom properties do not work. The CMS UI just gives an empty text-input field without the [...] button next to it.

Steps to reproduce.

01. Create a custom property

    public class CustomDropDownListProperty : PropertyDropDownList
        public override IPropertyControl CreatePropertyControl()
            return new CustomDropDownListControl();
    public class CustomDropDownListControl : PropertyDropDownListControl
        // not overriding anything


02. assign it to a pagetype:

        [Display(GroupName = Global.GroupNames.SiteSettings, Name = "Custom dropdown")]
        public virtual string CustomDropdown { get; set; }


03. Check out the property in Edit mode..

PS: I have also filed an incident report for this issue.

Nov 01, 2012 14:30

Does it work in the "legacy" edit mode?

Nov 01, 2012 15:04


It also worked in the Preview release in normal edit mode.

Edited, Nov 01, 2012 15:32

The EditorHintAttribute is not inherited so you will need to add one to your custom property.

public class CustomDropDownListProperty : PropertyDropDownList


Nov 01, 2012 17:17

So it's not a bug, good :)

But, now a dropdownlist is created for me. So how do I access this dropdown to load items?

Nov 01, 2012 18:03

You'll need to create a SelectionFactory to handle the logic for selecting the items, then you'll need a EditorDescriptor to associate the custom property with it. It will mean you need to have a custom EditorHint/UIHint name.

Here is a blog post from Linus which I think is pretty similar to what you are doing

Let us know if you get stuck :)

Nov 02, 2012 9:49

If you just have a "regular" drop down with a custom set of values I recomend implementing this using the EPiServer 7 way instead of trying to get your legacy property working. Not much code required and you can read how to do it here:

Nov 02, 2012 9:50

I have the same problem. I have some complex custom properties which don't render any more in Epi7. Can you please advise what is the way forward in EpiServer 7 to create custom properties based on complex objects? (possibly using mvc)



Dec 04, 2012 14:42

Hey Kayvan, I'm not quite sure what you're after. Are you having issues creating the custom property in the backend or are you having problems creating an editor for the front end? Linus has several blog posts regarding these topics that should hopefully help you:

Dec 04, 2012 16:18

Hi Ben

I can create the propety as I did in CMS6. I normally created them as a subclass of PropertyData and then overrided the CreatePropertyControl() method to create controls for Edit, and View mode. Something like Joel's example of creating a custom property.

What I am looking for is to find out the best practices for creating custom property types in Episerver 7 to be used in PageTypes and BlockTypes. I haven't seen any example for Epi7 about how to create custom properties inheriting from PropertyData or PropertyString etc.

My current implemebtation in Epi7 works for edit mode, but for some reason doesn't work in View mode.

Here is a piece of code representing a sample PropertyControl:

public class PropertyTabControl : PropertyLongStringControl
        Override CreateXXXControls to control the appearance of the property data in different rendering conditions.

        public override void CreateDefaultControls()        - Used when rendering the view mode.
        public override void CreateEditControls()           - Used when rendering the property in edit mode.
        public override void CreateOnPageEditControls()     - used when rendering the property for "On Page Edit".

public override void CreateDefaultControls() { var ctrl = new HtmlGenericControl { InnerHtml = "<p>some content..</p>" }; Controls.Add(ctrl); } public override void CreateEditControls() { Controls.Add(new TextBox { Text = "some content.." }); } }


Dec 04, 2012 18:17

I wrote a blog post to summarize the diffrences for properties in EPiServer 6 and 7:


Dec 05, 2012 8:47

Kayvan, when you meant a custom property based on a complex object, was it something block can help? Having it as a block you don't have to care about editors anymore, since EPiserver will automatically scaffold.

If you still want to write your own custom property editor based on a typed model, you can use FormContainer to automatically create the input UI. Here is a quick guide: Object editing guide

Edited, Dec 05, 2012 15:56

Thank you Duong,

I need to clarify a bit what I mean by custom complex property. Yes, I can get the same functionality using Blocks for peoperties which are made up of simple episerver types such as xhtmlstring, String, Url, etc. But, what if I need a full flexibility of editing a property value and rendering it in the view mode. Please look at the following picture which is an snapshot of one of the complex properties I have in EpiServer 6.


Here, I had a custom object called Tag, which has different properties and I had full flexebility of adding items to a lits, re-ordering items using drag n drop, deleting, etc. Then, I needed to take care of saving and loading the property value by overriding Save and Load methods in Property class.

But, I'm still not sure what is the best way to do complex object properties in EpiServer 7.





Dec 05, 2012 16:29

I would suggest a ContentArea property and a Tag block. The block would only need an XHTML property and a boolean property. Then that way you get the adding, removing, drag and drop sorting all for free from the ContentArea!

You would just have to handle the data differently on the server side (however I imagine this would be easier than what you currently have).

Dec 05, 2012 17:00

There are problems with that. We need to create a new instance of the Tag block every time we want to add a new tag to a page. So, we will end up with hundreds of instances of this block type (for all pages). And also, on the child pages, we need to query the blocks of type Tag on the parent page and see which one has the boolean tag selected to be cascaded and so on.

However, this is only an example of one of the complex properties we have. Others also may have properties relying on complex C# objects.



Edited, Dec 05, 2012 17:10

Previously, you would be able to define your complex C# object class having any type of properties you need and then just subclass from PropertyData class and create your controls for view/edit modes. As you know you needed to override Save and Load methods of your propety and EpiServer would serialize/deserialize your complex object for persistence/loading purposes. 

I know we can imlement 90% of custom properties in EpiServer 7 using blocks and we are converting most of them to blocks now. However, does this mean that we won't be able to create properties based on List of Complex objects any more in the new version?


Dec 05, 2012 17:17

Oh wow, ok in that case a content area wouldn't work for you. You can definitely implement lists of complex objects in EPiServer 7. The main difference would be that you would need to build the UI for it with JavaScript using dojo/dijit and have a EditorDescriptor that maps that property type to the front-end control.

Dec 05, 2012 17:38

Kayan, I have tried to create a generic editor for "list of object"-like properties you mention. It is quite easy with the support we have had from EPiServer Object editing framework. But there is one issue which makes it not working on RTM version. I will try if I can find a nice work around, then I will write a blog post about that.

Dec 07, 2012 11:23

Hi Duong


Thanks for the help. But, bear in mind that Editing is not a problem in this case as you mentioned EpiServer 7 provided ways to enrich editing. The main problem I see here is Persisting and Loading custom C# objects (i.e. Person) in Episerever. I achieved this in EpiServer 6 by creating customProperty and a propertyControl and managing view and edit modes together with saving and loading my custom (complex) object.

Not sure if we need to go that way in EpiServer 7.




Dec 07, 2012 11:31

There is not much changed regarding creating custom properties to store complex values in EPiSerer 7 compared to EPiServer 6. The only difference I see is that you need to return the value type in PropertyValueType with the type that matches your typed model. There is a sample in the new Alloy Samples Templates that show how to create a custom property that has a custom value type (PropertyStringList).

Of course it's still a bit of work to get a custom property containing a list working, but we hope to be able to add support for both editing and storage soon to remove the need for partner developers to write this code.

Dec 07, 2012 11:45

But this example in Alloy, doesnt use PropertyControl. (CreatePropertyControl()) is written to return null. So, its using the default editor.

I tried to port one of my custom properties to EpiServer 7. However, EpiServer 7 doesn't call my customPropertyControl method called: CreateEditControls().


This is why I cannot use my custom editor.






Dec 07, 2012 17:27

The example in Alloy shows the following:

PropertyStringList - Custom property responsible for converting the internal string to a String[] that you can use on your model classes.

StringList - Editor descriptor responsible to assign an editor (alloy.editors.StringList) and potentially any additional values.

alloy.editors.StringList - Client side editor that is responsible to edit the item.

[Template] - There is no custom template for this type but you can check for instance ContactDetailsByPageReference to see how a template is registered.

And yes, CreateEditControls will never be called in this scenario. If you want to have the legacy edit support you can add an EditorHint attribute to your property class and the legacy editing (inside a dialog) should kick in for your type.

public class YouPropertyClass : PropertySomething

Dec 07, 2012 18:00
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.