How to Create a Custom DropDownList
To create a custom DropDownList to be used in Edit Mode start with creating a Custom Property.
- Right-click the project root node and select Add -> New Item...
- Select the EPiServer Node
- Choose Custom Property and type a name for the property
- In the "Create Custom Property" dialog that follows, select Derived and choose Longstring as the parent type (also make sure that "Create an associated Control used for rendering the custom property" is checked)
Add a DropDownList instance to your class.
System.Web.UI.WebControls.DropDownList _DropDown = new System.Web.UI.WebControls.DropDownList();
This instance will be used to manipulate your controls rendering and data.
To make this control be the one rendered, override the CreateEditControls method and add the DropDownList instance to the control set.
public override void CreateEditControls() { _DropDown.Items.Add("An item"); this.ApplyControlAttributes(_DropDown); Controls.Add(_DropDown); }
To make sure any changes made to your control data in edit mode is saved, you need to override the ApplyEditChanges method.
The control is now ready to be added to and used in EPiServer templates in Edit Mode.
Additional Information
How to Create a Custom PropertyStylesheet Picker in Edit Mode