RequiredFieldValidator and UserControl

D

DougS

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
 
M

Marina

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.
 
G

gabe garza

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
ScottChare

Latest Threads

Top