Hello
I have a form with some TextBoxes I would like to validate.
Say for example:
- 1 form
- 2 Textboxes
- 1 Button
- 1 Error Provider
for each TextBox, code like
when I tab from one TextBox to another, I can see the ErrorProvider in action if the TextBox was left blank.
But say the form loads, focus on first TextBox and directly click on button (no tab). In the click event I want to validate my page so do validate()
But my second TextBox is not validated (because it didn't got focus at any moment)
How can I ask that ALL my controls should be validated and not only the last one ?
Thanks,
I have a form with some TextBoxes I would like to validate.
Say for example:
- 1 form
- 2 Textboxes
- 1 Button
- 1 Error Provider
for each TextBox, code like
Visual Basic:
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If Me.TextBox1.Text = String.Empty Then
Me.ErrorProvider1.SetError(Me.TextBox1, "Required")
End If
End Sub
when I tab from one TextBox to another, I can see the ErrorProvider in action if the TextBox was left blank.
But say the form loads, focus on first TextBox and directly click on button (no tab). In the click event I want to validate my page so do validate()
But my second TextBox is not validated (because it didn't got focus at any moment)
How can I ask that ALL my controls should be validated and not only the last one ?
Thanks,