Custom properties

Vote:
 
Hi Does anyone have a COMPLETE example of creating a custom property in CMS? Specifically, I want to create drop down list of options. Thanks
#15782
Mar 25, 2008 19:07
Vote:
 
Here is one: using System; using System.Collections.Generic; using System.Text; using EPiServer; using EPiServer.Core; using EPiServer.DataAbstraction; using EPiServer.PlugIn; using EPiServer.Web.PropertyControls; using System.Web.UI.WebControls; namespace EPiServerDemo.PropertyTypes { /// /// Custom PropertyData implementation /// [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; } } }
#16346
Mar 25, 2008 19:08
Vote:
 
Oh. It's quite simple really! I managed to figure out how to create one eventually (by using Reflector :) but this is better. Thanks
#16347
Mar 25, 2008 19:08
Vote:
 
Great - but, could this sort of thing be added to the CMS documentation, please? I spent too much timem searching the Tech Notes, SDK, forums before coming across this sample. The documentation remains very thin in places, as shown by the number of repeat queries in this forum. There have been some fundamental changes with CMS and we really could do with some solid documentation to go with them. Thanks.
#16348
Mar 25, 2008 19:08
Vote:
 
Ian, I second your comment.
#16349
Mar 25, 2008 19:08
Vote:
 
Im using this solution but I'm populating the dropdown with data depending on the setting of a dynamic property on the current page. This works nice as long as the page exists and I actually can get CurrentPage. When creating a new page I cant get hold of the Dynamic property because of the CurrentPage has the value of 0. The page isnt created yet. Any ideas on how to solve this? Populate the dd at a later state but when? /Mats Selberg
#16350
Mar 25, 2008 19:08
Vote:
 

hi Mari Jørgensen, I am using the same method you said but it is showing me No source Available page while debugging(In Episerver7).I have ignored that message and continued by selecting My demo dropdown from the properties list of that pagetype. But, in Edit mode it displays an empty field instead of a dropdown. What may the issue?

Here is the description of the Debugging error.

 

Locating source for 'http://server/EPiServer/CMS/Admin/EditPropertyDefinition.aspx'. (No checksum.)
Looking in script documents for 'http://server/EPiServer/CMS/Admin/EditPropertyDefinition.aspx'...
Looking in the projects for 'http://server/EPiServer/CMS/Admin/EditPropertyDefinition.aspx'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\atlmfc'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vc7\crt'...
The debugger will ask the user to find the file: EPiServer\CMS\Admin\EditPropertyDefinition.aspx.
The user pressed Cancel in the Find Source dialog. The debug source files settings for the active solution have been modified so that the debugger will not ask the user to find the file: http://server/EPiServer/CMS/Admin/EditPropertyDefinition.aspx.
The debugger could not locate the source file 'http://server/EPiServer/CMS/Admin/EditPropertyDefinition.aspx'.

 

I have created a class (PageType) with the name of DropDownCustomControl in the Models Folder. Is it right way to do? Please help me out by replying to this.

#81644
Edited, Feb 21, 2014 13:25
Vote:
 

Can you share the full process.....of creating the custom dropdown property?

#180488
Jul 12, 2017 14:17
Vote:
 

@Bhargav, this thread is about EPiServer CMS v5 which you are hopefully not currently using.

If you want to know how to create a drop down property in a recent version, please check out https://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/built-in-property-types/Single-or-multiple-list-options/ for information.

#180504
Jul 12, 2017 23:47
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.