I have a requirement to add a RequiredFieldValidator and RegularExpressionValidator to a dynamically created textbox in a dynamically generated tablecell, inside a Web User Control in the Content Area of a Page created from a Master.
The problem, as you can probably guess, is trying to dynamically set the ControlToValidate property to look at my dynamically created text box.
After some research the code now:
Sets the id of the ControlToValidate. Values I have attempted to use:
Needless to say I am still unable to convince the Validator to "see" the control it is supposed to validate and I am completely out of new ways to approach the problem.
EDIT: Further detective work has lead me to the point that the page doesn't have a problem until the page_load event has finished. The server seems to have a problem after the code for building the page has finished executing. I'm starting to wonder if I'm actually adding the controls into naming containers much too late instead of too early.
Any suggestions?
What about creating a user control that contains the textbox and the two validators? Then you can set the ControlToValidate
via Visual Studio, as usual, and then dynamically add this new control to your tablecell dynamically.