Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   asp validation controls not working at runtime (http://www.velocityreviews.com/forums/t771586-asp-validation-controls-not-working-at-runtime.html)

Graham Usherwood 10-31-2003 09:08 AM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57