Adding validators to CompositeControl

M

Mantorok

Hi all

I finally got around to creating some WebControl classes, however I want to
add some validation to my custom control, it's a descendant of
CompositeControl.

I get the exception: Unable to find control id 'txtForename' referenced by
the 'ControlToValidate' property of 'valType'

Here is how I'm creating the validtor(s):

protected override void CreateChildControls()

{

// Create the custom validator

CustomValidator customVal = new CustomValidator();

customVal.ID = ID_CUSTOMVAL;

customVal.ServerValidate += new
ServerValidateEventHandler(validator_ServerValidate);

customVal.Text = TEXT_VALIDATOR;

Controls.Add(customVal);

// Create the compare validator

CompareValidator typeVal = new CompareValidator();

typeVal.ID = ID_TYPEVAL;

typeVal.Operator = ValidationCompareOperator.DataTypeCheck;

typeVal.Text = TEXT_VALIDATOR;

typeVal.ControlToValidate = ID;

Controls.Add(typeVal);

base.CreateChildControls();

}


Any ideas?

Thanks
Kev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top