I am trying to create a new property type that should be rendered as checkboxes in editmode. The type is derived from PropertyString.
The property renders itself as it should but the values won't get stored in EPiServer. What kind of controls should I use and do I have to add more things like ParseToObject()?
Here is some code from CreateChildControls():
CheckBoxList cbList = new CheckBoxList();
CopyWebAttributes(container, cbList);
cbList.RepeatColumns = 3;
cbList.RepeatLayout = RepeatLayout.Table;
cbList.Items.Add(new ListItem("Value A", "a"));
cbList.Items.Add(new ListItem("Value B", "b"));
cbList.Items.Add(new ListItem("Value C", "c"));
container.Controls.Add(cbList);
container.Controls.Add(CreateParseValidator(cbList));
- Johan
The source code for PropertyWeekday is available in the SDK under source\EPiServer\SpecializedProperties, it does the exact same operation.
The trick is that you have to add your own ParseValidation handler to read back settings from your control.
CheckBoxList cbList = new CheckBoxList(); CopyWebAttributes(container, cbList); cbList.RepeatColumns = 3; cbList.RepeatLayout = RepeatLayout.Table; cbList.Items.Add(new ListItem("Value A", "a")); cbList.Items.Add(new ListItem("Value B", "b")); cbList.Items.Add(new ListItem("Value C", "c")); container.Controls.Add(cbList); container.Controls.Add(CreateParseValidator(cbList));
- Johan