473,401 Members | 2,139 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,401 software developers and data experts.

dynamically adding validation controls

Hi,

I have a page with a repeater control that contains textboxes. I'm trying
to create a validation class that is called by my page. A method in this
class iterates through all the controls on the page. On encountering a
TextBox control, it looks at the ID to discern the field the TextBox
represents, and then creates the appropriate validation controls and adds
them to the page. The controlToValidate property of each validation control
is the ClientID of the current TextBox in question.

When I run the page I get an error such as: Unable to find control id
'SchoolsRepeater__ctl0_txtStudent_LastName' referenced by the
'ControlToValidate' property of ''.

Of course the same type of error will occur when I use the control.ID as the
controltovalidate property.

Currently this Validation class method is called on the page at the end of
the page_load method. I've also tried putting it in the OnInit method, to no
avail.

Suggestions? Thanks.

Jack.
Nov 19 '05 #1
1 4705
The basic problem is that the ControlToValidate property requires the ID of
the other control, not the ClientID. This means that both the validator
control and its textbox must be in the same naming container. (Each row of a
Repeater is a different naming container.) So be sure to put the validator
into each row and use the ID property.

FYI: I wrote a replacement to Microsoft's validators, "Professional
Validation And More" (http://www.peterblum.com/vam/home.aspx). Its 22
validators allow attaching controls that are in other naming containers.
There are numerous enhancements in Professional Validation And More to
address the limitations of the Microsoft validators and give users the
features they've requested but haven't found in Microsoft's validators.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
Hi,

I have a page with a repeater control that contains textboxes. I'm trying
to create a validation class that is called by my page. A method in this
class iterates through all the controls on the page. On encountering a
TextBox control, it looks at the ID to discern the field the TextBox
represents, and then creates the appropriate validation controls and adds
them to the page. The controlToValidate property of each validation
control
is the ClientID of the current TextBox in question.

When I run the page I get an error such as: Unable to find control id
'SchoolsRepeater__ctl0_txtStudent_LastName' referenced by the
'ControlToValidate' property of ''.

Of course the same type of error will occur when I use the control.ID as
the
controltovalidate property.

Currently this Validation class method is called on the page at the end of
the page_load method. I've also tried putting it in the OnInit method, to
no
avail.

Suggestions? Thanks.

Jack.

Nov 19 '05 #2

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

Similar topics

0
by: Trillium | last post by:
I am trying to upgrade a straight ASP project into .NET, but I am new at ..NET, and there seem to be so many different ways to do things. I am new to ..NET and need some guidance as to which...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
2
by: sj via .NET 247 | last post by:
I have a web form <%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="test"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> &nbsp;...
1
by: Jeffrey Todd | last post by:
I have successfully created functionality that mostly models what I'm trying to do - which is dynamically insert controls into a user control (ascx), and insert validation controls, also...
3
by: Mark Denardo | last post by:
I'm trying to dynamically create and add controls to a web page: Label obj1 = new Label(); DropDownList obj2 = new DropDownList(); Controls.Add(obj1); Controls.Add(obj2); But I get the...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
4
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.