November Happy Hour will be moved to Thursday December 5th.

Problem with Custom property CMS 5

Vote:
 

Hello

I have created a very simple custom property

 

    [Serializable]
    [PageDefinitionTypePlugIn(DisplayName = "My demo dropdown")]
    public class MyDropDownCore : EPiServer.Core.PropertyString
    {
        public override IPropertyControl CreatePropertyControl()
        {
            return new MyDropDownPropType();
        }
    }
    public class MyDropDownPropType : EPiServer.Web.PropertyControls.PropertySelectControlBase
    {
        protected override void SetupEditControls()
        {
            base.SetupEditControls(); DropDownList inputControl = this.EditControl;
            inputControl.Items.Add("Red");
            inputControl.Items.Add("Blue");
            inputControl.Items.Add("Green");

            inputControl.SelectedValue = this.PropertyData.Value as string;
        }
    }


but it wont show in the Type dropdownlist on the create property in admin mode, whats wrong?

Thanks in advance!

/Fred
#38651
Apr 16, 2010 11:22
Vote:
 

You need to add inputControl to the control collection.

Controls.Add(inputControl);
Frederik
#38657
Apr 16, 2010 14:43
Vote:
 

Thanks for your answer, but it doesnt make any difference. It still doesnt show upp in the Type dropdown.

Is there any other settings to make it appear? does it have to be in a specific namespace? or do I have to add it through the "Edit Custom Property Types" in admin?

 

Thanks in advance

/Fred

#38660
Apr 16, 2010 16:59
Vote:
 

No, you don't have to add it to a specific namespace. If you check under Custom Property Types in admin mode does it appear there? If not, try inheriting from PropertyStringControl instead of PropertySelectControlBase.

Frederik

#38666
Apr 16, 2010 18:49
Vote:
 

I still cant see my custom property under Custom Proeprty Types in Admin mode, my code looks lite this now:

 

[Serializable]

[PageDefinitionTypePlugIn]

public class MyDropDownCore : EPiServer.Core.PropertyString

{

public override IPropertyControl CreatePropertyControl()

{

return new MyDropDownCoreControl();

}

}

public class MyDropDownCoreControl : EPiServer.Web.PropertyControls.PropertyStringControl

{

 

protected DropDownList inputControl;

 

 

public override void CreateEditControls()

{

base.SetupEditControls();

inputControl.Items.Add("Red");

inputControl.Items.Add("Blue");

inputControl.Items.Add("Green");

 

inputControl.SelectedValue = this.PropertyData.Value as string;

Controls.Add(inputControl);

}

 

public MyDropDownCore MyDropDownCore

{

get

{

return PropertyData as MyDropDownCore;

}

}

}



 

#38689
Apr 19, 2010 9:13
Vote:
 

Hi Fred

Take a look at this article: How to create custom properties in EPiServer CMS 5.

Frederik

#38704
Apr 19, 2010 18:56
Vote:
 

Thanks for your help Frederik,

It was I that screwed up with something completely different. Now it works.

#38705
Apr 19, 2010 19:10
* 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.