473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accessing the ControlToValidate control in a Validator

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
nj********@hotmail.com
http://www.nathansokalski.com/
Jun 27 '08 #1
1 1407
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
nj********@hotmail.com
http://www.nathansokalski.com/
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: edi | last post by:
Hi, Are there any differences between CompareValidator.ControlToCompare and CompareValidator.ControlToValidate? For example if I have TextBox controls: TextBox1 and TextBox2 what are the...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
2
by: Sunil Sabir | last post by:
Dear All, I am using ValidationSummary,RequiredField Validator and Regular Expression Validator in my ASP.net form. I want to display error messages only in the ValidationSummary Control. But...
3
by: tshad | last post by:
I am trying to put together a user control (.ascx). Can you access an outside control from it? My control: login2.ascx ****************************************************************...
1
by: Srini | last post by:
<tr> <td nowrap=nowrap >Start Date/Time</td> <td =nowrap><zw:Calendar ID="calStart" runat=server DisplayTime=true Mandatory=true ReadOnly=true /> </td> <td nowrap=nowrap>Appointment Type</td>...
4
by: Steven Nagy | last post by:
Hi all, I have a custom user control in an ASP.NET app (.NET 2.0). This control needs a public property called "ControlToValidate" which accepts strings. I need to be able to declare it much as...
3
by: Nathan Sokalski | last post by:
I have a validator that I wrote by inheriting from BaseValidator. At certain points in the code, I need to access other controls on the page containing the validator. I have the IDs of these...
2
by: DaveyP | last post by:
Hi. I'm writing a Javascript subroutine for client side validation using a custom validator. I know I have the ".value" attribute available, and want to know that other attributes I can access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.