You use Visual Studio .NET using C# to create a payment form for customers of GeekBooks Inc. The form enables users to enter credit card payment information. The form contains a text box named txtCreditCardNo.
If a user enters an invalid telephone number, the form must notify the user of the error. You use a function named ValidateCreditCardXMLService that calls an XML web service to validate the credit-card number entered. You include an ErrorProvider control named ErrorProvider1 in your form.
Which additional code segment should you use?
Answer(s)
- Private Sub txtCreditCard_Validated _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.SetError(txtCreditCard, "Invalid Credit Card.")
End If
End Sub
- Private Sub txtCreditCard_Validated _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles txtCreditCardNo.Validated
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.SetError(txtCreditCard, "Invalid Credit Card.")
End If
End Sub
- Private Sub txtCreditCard_Validating _
(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles txtCreditCardNo.Validating
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.GetError(txtCreditCard)
End IF
End Sub
- Private Sub txtCreditCard_Validated _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles txtCreditCardNo.Validated
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.GetError(txtCreditCard)
End If
End Sub
- Private Sun txtCreditCard_Validating _
(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles txtCreditCardNo.Validating
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.UpdateBinding()
End If
End Sub
- Private Sub txtCreditCard_Validated _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles txtCreditCardNo.Validated
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.UpdateBinding()
End If
End Sub
Correct Answer
Private Sub txtCreditCard_Validated _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles txtCreditCardNo.Validated
If ValidateCreditCardXMLService() = False then _
ErrorProvider1.SetError(txtCreditCard, "Invalid Credit Card.")
End If
End Sub