asp validation controls not working at runtime

Discussion in 'ASP .Net Web Controls' started by Graham Usherwood, Oct 31, 2003.

  1. 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"
     
    Graham Usherwood, Oct 31, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Srinivasa Raghavan

    ASP.Net Validation controls not working in netscape

    Srinivasa Raghavan, Jul 29, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    464
    S. Justin Gengo
    Jul 29, 2003
  2. Srinivasa Raghavan Sethuraman

    Re: ASP.Net Validation controls not working in netscape

    Srinivasa Raghavan Sethuraman, Jul 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    Srinivasa Raghavan Sethuraman
    Jul 29, 2003
  3. Paul M
    Replies:
    0
    Views:
    418
    Paul M
    Apr 11, 2004
  4. Keith Free Ellis
    Replies:
    4
    Views:
    4,207
    Steven Cheng[MSFT]
    Jul 14, 2004
  5. Alan Silver
    Replies:
    1
    Views:
    3,804
    Alan Silver
    Aug 2, 2005
Loading...

Share This Page