CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Posts
    1

    Question Dynamic control validation problems

    I have a table with text boxes that i generate dynamically. I need to add some validation control to these text boxes.

    Can anyone tell me where to put the validation code.

    My code to generate the table is :

    <code>

    private sub create entry fields(num as integer)
    Dim j As Integer
    Dim no As Integer = CInt(noOfPermitee)
    For j = 0 To num - 1
    Dim tr As New TableRow
    Dim td1 As New TableCell
    Dim txt1 As New TextBox
    txt1.TextMode = TextBoxMode.MultiLine
    td1.Controls.Add(txt1)


    Dim td2 As New TableCell
    Dim txt2 As New TextBox
    txt2.TextMode = TextBoxMode.MultiLine
    td2.Controls.Add(txt2)
    tblUserInputs.Rows.Add(tr)
    Next
    End sub

    </code>

    I call this sub in a button click event.

    I am able to write the required field validator. I just don't know where to write the validation code.

    My validation code is:

    Dim reqval1 As New RequiredFieldValidator
    reqval1.ControlToValidate = "txt1"
    reqval1.ErrorMessage = "*"
    reqval1.Text = "Please enter the agent name

    Where should i put this code for the validation to fire.

    Thank you

  2. #2
    Join Date
    Mar 2000
    Location
    Vancouver, BC, Canada
    Posts
    278

    Re: Dynamic control validation problems

    you could do it in submit button's onclick event
    <submit onclick="validateForm()" ...... />

    i've also seen form tags have it:
    <form method=post onsubmit="validateForm()">
    David Meikle
    Quantum Unit Solutions, LLC
    www.quantumunit.com

  3. #3
    Join Date
    Mar 2005
    Location
    India
    Posts
    102

    Re: Dynamic control validation problems

    I too have almost the same problem. I have a Radiobuttonlist in the datagrid. I need to validate the radiobuttonlist. So where do i write the validation code in this case.
    I have place a Required field validator in the datagrid and set the controltovalidate property to the radiobuttonlist.This works, but if i want to write the validation code manually ,where do i place it?.
    Manjula
    ------------
    "To err is Human, and to blame it on a computer is even more so.."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured