Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Accessing the ControlToValidate control in a Validator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 20 May 2008 21:06 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

bruce barker - 20 May 2008 23:49 GMT
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)

> I am writing a Validator by inheriting from the BaseValidator class. I need
> to access the control referred to by the ControlToValidate property. Because
[quoted text clipped - 7 lines]
> get the ControlToValidate control in a Validator, since they are often used
> together. Any help would be appreciated. Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.