Property Types changes

In a previous version of CMS I created a custom property by inheriting from the EPiServer.Web.PropertyControls.PropertyTextBoxControlBase class. My class included these lines of code protected override void SetupTextBox(TextBox inputControl) { base.SetupTextBox(inputControl); inputControl.Text = this.PropertyData.Value as string; _myBox = inputControl; } The SetupTextBox method provided me with easy access to the textbox control created by the base class. In CMS RC3 this method has been removed from the PropertyTextBoxControlBase class (same goes for the SetupDropDownList method in PropertySelectControlBase). What is the reason for this?
Aug 07, 2007 10:19
Just to elaborate: In my custom property I'm overriding ApplyEditChanges() in order to check if the value entered is a valid email address public override void ApplyEditChanges() { TextBox _myBox = this.EditControl; string value = _myBox.Text; if (!IsValid(value)) { _myBox.BackColor = System.Drawing.Color.Orange; this.AddErrorValidator("Your entry is not a valid e-mail address!"); } else SetValue(value); } I've figured out that I could get hold of the control/textbox through the EditControl property. Would this be the way to go?
Aug 07, 2007 10:46
Hi Mari! You are correct in the asumption that you should override either the SetupEditControls or CreateEditControls methods and access the EditControl property (that will represent the actual input control as a TextBox, DropDownList etc). The difference betwen the SetupEditControls and CreateEditControls is that the default implementation of the CreateEditControls creates and sets up the input control and then calls SetupEditControls. So if you just want to set the value or alter the input control you should override SetupEditControls. If you want to control the creation of the input controls entirely you should override CreateEditControls (don't forget to call SetupEditControls in the end of the method so that you or third parts can alter the functionality in a inherrited control).
Aug 16, 2007 14:10