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

RequiredFieldValidator and UserControl

I'm attempting to put a RequiredFieldValidator next to a text box on a user
control. There will be a dozen of these controls added dynamically. At
runtime I get this error:

Unable to find control id 'txtValue' referenced by the 'ControlToValidate'
property of 'RequiredFieldValidator1'

Do validators only work on webforms?

Thanks,
Doug
Nov 19 '05 #1
2 2356
The problem is that controls that are on user controls, get renamed at run
time, so that if you have more then one of that user control on the page,
that everything will be unique.

If the requiredfieldvalidator can't deal with this, it may be worth it to
run your own version. It's not too hard, and you will only need to do it
once since you are encapsulating all the functionality in your usercontrol.

"DougS" <do**@nospam.com> wrote in message
news:%2*****************@TK2MSFTNGP14.phx.gbl...
I'm attempting to put a RequiredFieldValidator next to a text box on a
user control. There will be a dozen of these controls added dynamically.
At runtime I get this error:

Unable to find control id 'txtValue' referenced by the 'ControlToValidate'
property of 'RequiredFieldValidator1'

Do validators only work on webforms?

Thanks,
Doug

Nov 19 '05 #2
Your textbox ID is prefixed with the user control name.
I'm pretty sure that's all your missing.

"DougS" <do**@nospam.com> wrote in message
news:%2*****************@TK2MSFTNGP14.phx.gbl...
I'm attempting to put a RequiredFieldValidator next to a text box on a
user control. There will be a dozen of these controls added dynamically.
At runtime I get this error:

Unable to find control id 'txtValue' referenced by the 'ControlToValidate'
property of 'RequiredFieldValidator1'

Do validators only work on webforms?

Thanks,
Doug

Nov 19 '05 #3

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

Similar topics

6
by: BK | last post by:
I'm having a really strange problem with and HtmlSelect server control (listbox) and a RequiredFieldValidator that I am trying to use to make sure that someone has items in the listbox. The way...
0
by: Nicolas | last post by:
How can I have only one RequiredFieldValidator to control two TextBox webcontrols so that only one message is displayed <asp:Label id="lbl_UserName" runat="server"></asp:Label><br> <asp:TextBox...
3
by: me | last post by:
Is there any particular reason why a requiredfieldvalidator cant validate a listbox? I have bound the two together but the validator always returns false on isvalid and so does the Page, no matter...
7
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and...
4
by: James | last post by:
Hello, I have a RequiredFieldValidator for several textbox controls on a form. Here's an example with the RequiredFieldValidator. EnableClientScript, Enabled, and Visible are set to true for...
4
by: Joe | last post by:
Hello, I have created a login page using dotnet. I am using requiredFieldValidator and noticed that the code works fine in IE but not in Netscape, Opera, Mozilla, Firefox, etc. For example...
5
by: Fernando Lopes | last post by:
Hi. I want to show an image in a requiredfield validator instead of "*". So, I 'm set the requiredfieldvalidator attributes like following: <asp:RequiredFieldValidator id=rfvFirstName...
1
by: Andrew Robinson | last post by:
Is it possible to have a RequiredFieldValidator that targets a UserControl? <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="PhoneUserControlHome"...
2
by: Christina | last post by:
Hello !! I am creating a dynamic textbox and want to validate it using the requiredfieldvalidator. These are the steps which I tried: ==================================================== 1)...
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?
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.