|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dynamically adding validation controlsI 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. 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: PLB***@PeterBlum.com Creator of "Professional Validation And More" at http://www.peterblum.com/vam/home.aspx Show quoteHide quote "Jack" <J***@discussions.microsoft.com> wrote in message news:94D65947-7BC3-4EFA-BAC1-6F8DC2A575E2@microsoft.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.
unicode characters in web form aspx pages, utf-8
Javascript not working when part of asp.net page. DataGrid Sort Expression for a date in format 'dd mmm yy' how do i find what page is causing my performance prob? Open new project from web not compiling Intranet/Internet portals detecting empty 'input type=file' fields? Selecting Dataset records Reading xml File Upload Control |
|||||||||||||||||||||||