|
-
July 19th, 2005, 11:29 AM
#1
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
-
July 19th, 2005, 10:41 PM
#2
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()">
-
July 20th, 2005, 09:46 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|