New Property DataType

I’ve created a new Property datatype. It is a radiobuttonlist which contains 2 items. By default none of them are selected, but I want the field to be required. Therefore, if a user tries to publish without selecting an item, I want an error message to be displayed. As you can see below I have tried to solve this by adding a required field validator, but it doesn’t work. You’re allowed to publish the page. [ EPiServer.PlugIn.PageDefinitionTypePlugIn(DisplayName = "Regjeringssensitivt") ] public class GovSensitive : EPiServer.Core.PropertyString { private RadioButtonList rdbList; public override void CreateChildControls(string renderType, System.Web.UI.Control container) { switch( renderType.ToLower()) { case "edit": rdbList = new RadioButtonList(); rdbList.ID = Name; CopyWebAttributes(container,rdbList); rdbList.Items.Add(new ListItem("Regjeringssensitivt","True")); rdbList.Items.Add(new ListItem("Ikke Regjeringssensitivt","False")); if(ToString().Length > 0) { ListItem selectedItem = rdbList.Items.FindByValue(ToString()); if (selectedItem != null) selectedItem.Selected = true; else rdbList.SelectedIndex = 0; } CopyWebAttributes(container,rdbList); container.Controls.Add(rdbList); RequiredFieldValidator reqVal = new RequiredFieldValidator(); reqVal.ControlToValidate = rdbList.ID; reqVal.Display = ValidatorDisplay.Dynamic; reqVal.EnableClientScript = false; reqVal.ErrorMessage = "Du må angi hvorvidt innhold er regjeringssensitivt eller ikke"; container.Controls.Add(reqVal); break; default: base.CreateChildControls(renderType,container); break; } } }
Nov 16, 2004 10:18
* 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.