Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Accessing the ControlToValidate control in a Validator

Reply
Thread Tools

Accessing the ControlToValidate control in a Validator

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      05-20-2008
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      05-20-2008
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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy access to the control specified in a validator's ControlToValidate property Nathan Sokalski ASP .Net 0 03-08-2010 08:23 PM
Accessing the ControlToValidate control in a Validator Nathan Sokalski ASP .Net 1 05-20-2008 10:49 PM
Accessing the ControlToValidate control in a Validator Nathan Sokalski ASP .Net Web Controls 1 05-20-2008 10:49 PM
Custom Control needs ControlToValidate Steven Nagy ASP .Net 4 05-08-2007 03:56 AM
custom validator and ControlToValidate in a composite control... Donal McWeeney ASP .Net Building Controls 1 09-29-2004 08:45 AM



Advertisments