Hi Peter,
Thanks for the info. It backs up what I believed to be true. I ended up
creating a required field validator which replicates the system's as well as
a base validator which derives from the system's. This lets me override the
necessary methods to correct the naming container issue. A bit of a PITA,
but now I have a clean solution for all the controls in my assembly that
need it.
-Pete
"Peter Blum" <> wrote in message
news:#...
> Hi Pete,
>
> By design, the ControlToValidate property is limited to the current naming
> container (which you've proven.)
>
> The typical answer is to the confirm that all controls are in the same
> naming container. One way you might do this is by adding the
> RequiredFieldValidator inside your customcontrol when the Required
property
> is true. They will both be in the same naming container.
> Another is to determine if your control truly needs an INamingContainer.
> Often when a composite control creates child controls, it assigns their
IDs
> based on its own ID in the CreateChildControls method. So long as the page
> developer assigns the ID property to the control before
CreateChildControls
> is called, everything has a unique ID and will work fine without
> INamingContainer.
>
> FYI: I built a replacement to Microsoft's validators (see my tagline). It
> overcomes numerous limitations in validation including the
INamingContainer
> one. On my validators, you can either assign the ID or a reference to the
> control. When you assign a reference to the control, it can be in any
naming
> container. When you assign an ID it can be in the same or any parent
naming
> container.
>
> --- Peter Blum
> www.PeterBlum.com
> Email:
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
>
> "Peter Young" <> wrote in message
> news:...
> >I would like to have my control provide a Required property, and if this
> > property is true, attach a RequiredFieldValidator.
> >
> > This approach works fine for a 'simple' control, but it fails for a
> > composite control, where the control is implementing INamingContainer.
> >
> > It appears that the problem is inside of the system base validator - it
is
> > looking for the ControlToValidate like so:
> > this.NamingContainer.FindControl(name)
> >
> > In this case, the naming container is the control it's trying to find,
so
> > it
> > can't find it. It needs to search the parent naming container.
> >
> > Has anyone else run into this and found a simple workaround?
> >
> > Thanks for any help,
> > Pete
> >
> >
>
>