Start Validating textbox in c net

Validating textbox in c net

I got to know about implicit validation and explicit validation but I feel better to use implicit validation only because its on time error provider when user looses focus on text box or if he shifts to another textbox.

It returns a Dialog Result to detect wheather the OK or the Cancel button has been clicked.

The value can be obtained from the input/output parameter value.

Although if the users takes focus of the field, the "bad" data (such as "fdgfdg") is still left in the field.

So could some demonstrate how when focus is lost on the field, if the data is not valid, a default value will be entered instead e.g.

So before saving data, I want to validate whether all the required fields are filled (Text Boxes) by the user. I would rather use a generic function that would be passed each control on the form and based on the type of the control, separate validation logic would be written.

in case extra validation like restricting validation to some of the controls only, that would be decided at the function calling level.

Active Control property to the current form, focus events occur in the following order Enter Got Focus Leave Validating Validated Lost Focus When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order: Enter Got Focus Lost Focus Leave Validating Validated event provides the hook to perform the validation and Error Provider gives a nice consistent approach to providing the user with feedback on any error conditions.