custom validator and ControlToValidate in a composite control...

D

Donal McWeeney

The ControlToValidate property is wrecking my head.

I have a custom composite server control defined as follows:

internal abstract class MyControlBase : Control, INamingContainer
{...}

[ValidationProperty("ValidationValue")]
internal class MyControl : MyControlBase
{...}

MyControl in its CreateChildControls method creates the following:
- an array of RadioButton control
- a TextBox
- a custom validator that I have written.

If I set the validator ControlToValidate property to the TextBox it works
fine however it may not be created or rendered. The only thing I can be
guarnteed of rendering is the array or RadioButtons.

If I set the validator ControlToValidate to the ID of the instance of
MyControl I get the following error:

Unable to find control id 'idMyControl' referenced by the
'ControlToValidate'
property of 'idMyControl-rfv'.

Must ControlToValidate refer to a child of the naming container or can it be
the control that implements the naming container?

Is it possible in my custom validator to tell the base validator code not to
worry about the ControlToValidate property...

Help!!! Going beserk...

Thanks

Donal
 
D

Donal McWeeney

I think I found half the answer... I can override the ControlPropertiesValid
method and in that only continue checking the ControlToValidate property if
its not blank.

Still wondering about...

Must ControlToValidate refer to a child of the naming container or can it be
the control that implements the naming container?
 

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,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top