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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top