A
antonyliu2002
I am moving from Java to ASP .NET. Many .NET stuffs remain new to me.
I am wondering if it is possible to dynamically/programmatically enable
a validator.
Suppose that I have the following in my Web application:
Card Type:
o Master
o Visa
o Amex
Card Number:
___________________
If the user enters the card number, but forgets to select a card type,
I want to warn him that he must select a card type.
In other words, the RadioButtonList control validation of card type is
not required unless a valid card number is supplied.
Suppose the card number is validated with a RegularExpressionValidator
and the card type is validated with a RequiredFieldValidator.
Is it possible to do something like the Sub below?
Sub CardTypeValidator(sender As Object, args As
ServerValidateEventArgs)
If CardNumberValidator.IsValid() Then
//Enable CardTypeValidator here
End If
End Sub
I have not tried this. I want to know a little more before I give it a
shot. Thanks.
I am wondering if it is possible to dynamically/programmatically enable
a validator.
Suppose that I have the following in my Web application:
Card Type:
o Master
o Visa
o Amex
Card Number:
___________________
If the user enters the card number, but forgets to select a card type,
I want to warn him that he must select a card type.
In other words, the RadioButtonList control validation of card type is
not required unless a valid card number is supplied.
Suppose the card number is validated with a RegularExpressionValidator
and the card type is validated with a RequiredFieldValidator.
Is it possible to do something like the Sub below?
Sub CardTypeValidator(sender As Object, args As
ServerValidateEventArgs)
If CardNumberValidator.IsValid() Then
//Enable CardTypeValidator here
End If
End Sub
I have not tried this. I want to know a little more before I give it a
shot. Thanks.