T
theresa
Hello. I'm creating a form that has (up to) 10 identical panels on the
page, with each panel containing the same 8 textboxes for things like
school name, address, etc, and one dropdown box. The user chooses how
many schools they need to enter information for, and the form shows the
appropriate number of panels. All 10 panels are generated on page load,
then hidden until the user selects how many they need.
Now comes the tricky part. If the user selects "No" from the dropdown
box within a panel, the address for that panel needs to be required.
I've written a CustomValidator that refers to the Address textbox by ID
(eg. Address1). While the CustomValidator works, if I use this method I
will have to write separate CustomValidators for each of the 10 panels.
Is there any way to write one validator that would work for all 10
Address textboxes? Here's the code I've got so far:
Sub reqAddress(sender as Object, args as ServerValidateEventArgs)
Dim strAddress As String
Dim ddYesNo As String = CStr(args.Value)
strAddress = txtAddress1.Text // This is the line I want to make more
general
If ddYesNo = "No" And Len(strAddress)=0 Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
page, with each panel containing the same 8 textboxes for things like
school name, address, etc, and one dropdown box. The user chooses how
many schools they need to enter information for, and the form shows the
appropriate number of panels. All 10 panels are generated on page load,
then hidden until the user selects how many they need.
Now comes the tricky part. If the user selects "No" from the dropdown
box within a panel, the address for that panel needs to be required.
I've written a CustomValidator that refers to the Address textbox by ID
(eg. Address1). While the CustomValidator works, if I use this method I
will have to write separate CustomValidators for each of the 10 panels.
Is there any way to write one validator that would work for all 10
Address textboxes? Here's the code I've got so far:
Sub reqAddress(sender as Object, args as ServerValidateEventArgs)
Dim strAddress As String
Dim ddYesNo As String = CStr(args.Value)
strAddress = txtAddress1.Text // This is the line I want to make more
general
If ddYesNo = "No" And Len(strAddress)=0 Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub