Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.aspnet.buildingcontrols
Accessing the ControlToValidate control in a Validator
Nathan Sokalski
5/20/2008 8:07:00 PM
I am writing a Validator by inheriting from the BaseValidator class. I need
to access the control referred to by the ControlToValidate property. Because
ControlToValidate is a String, I will need to use the FindControl() method
using ControlToValidate as the argument. In most cases, this would work
perfectly fine, but as most of us know, there are some scenarios (such as
those involving Master pages) in which the NamingContainers can make this
harder than we would like. The GetControlValidationValue() method obviously
needs to reference the ControlToValidate control when it gets the validation
value, so I am wondering if there is some hidden way to make it easier to
get the ControlToValidate control in a Validator, since they are often used
together. Any help would be appreciated. Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansok...
1 Answer
bruce barker
5/20/2008 10:49:00 PM
0
the validator design logic requires the validator and the control to be
validated are in the same naming container. There is no hidden logic, the
base validator code just does a this.NamingContainer.FindControl().
if you know the fully qualified path you can specify it as:
parent1$parent2$child
you could make your own naming container that the validators were placed in
that had its own FindControl logic.
-- bruce (sqlwork.com)
"Nathan Sokalski" wrote:
> I am writing a Validator by inheriting from the BaseValidator class. I need
> to access the control referred to by the ControlToValidate property. Because
> ControlToValidate is a String, I will need to use the FindControl() method
> using ControlToValidate as the argument. In most cases, this would work
> perfectly fine, but as most of us know, there are some scenarios (such as
> those involving Master pages) in which the NamingContainers can make this
> harder than we would like. The GetControlValidationValue() method obviously
> needs to reference the ControlToValidate control when it gets the validation
> value, so I am wondering if there is some hidden way to make it easier to
> get the ControlToValidate control in a Validator, since they are often used
> together. Any help would be appreciated. Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
>
http://www.nathansok...
>
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Accessing the ControlToValidate control in a Validator
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password