Try our conversational search powered by Generative AI!

Property Types changes

Vote:
 
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?
#15728
Aug 07, 2007 10:19
Vote:
 
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?
#16241
Aug 07, 2007 10:46
Vote:
 
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).
#16242
Aug 16, 2007 14:10
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.
* 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.