![]() |
asp validation controls not working at runtime
I am trying to update tables selected by the user from a database.
The form textboxes and validation controls will reflect the contents of the table selected at runtime Therefore I need to create the controls at runtime. The controls are rendered into the form. But the validation controls always respond as invalid with the error message Validator.ErrorMessage = "too many characters" i.e the validation controls are not validating. 'on the aspx page is a standard table <asp:table id="Table1" Runat="server"></asp:table> 'Code behind adds rows, cells and validation controls to the table. Dim tblRow As New TableRow Dim tblCell1 As New TableCell Dim lblLabel As New Label lblLabel.Text = " " tblCell1.Controls.Add(lblLabel) tblRow.Cells.Add(tblCell1) 'Cell 2 textbox Dim tblCell2 As New TableCell Dim txbTextBox As New TextBox txbTextBox.ID = "cc" txbTextBox.Text = " " 'tblCell2.Controls.Add(txbTextBox) 'tblRow.Cells.Add(tblCell2) 'Cell 3 range valildator Dim tblCell3 As New TableCell Dim rgeValidator As New RegularExpressionValidator 'rgeValidator.ValidationExpression = "\w" rgeValidator.Display = ValidatorDisplay.Dynamic rgeValidator.EnableViewState = True rgeValidator.Enabled = True rgeValidator.EnableClientScript = True rgeValidator.ID = "validator2" rgeValidator.ControlToValidate = "cc" 'rgeValidator.Text = "Error" tblRow.Cells.Add(tblCell3) Table1.Rows.Add(tblRow) tblCell3.Controls.Add(rgeValidator) rgeValidator.ValidationExpression = "\w{2}" rgeValidator.ErrorMessage = "too many characters" |
| All times are GMT. The time now is 05:02 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.