Form validating event
Server side validation is performed by a web server, after input has been sent to the server.Client side validation is performed by a web browser, before input is sent to a web server.Most often, the purpose of data validation is to ensure correct user input.Validation can be defined by many different methods, and deployed in many different ways.I want to check what the user is writing in a textbox before I save it in a database. I guess I can always write some ifs or some try-catch blocks, but I was wondering if there's a better method.I've read something about Validating Events, but I am not sure how can I use them. Validating Event When you change the focus by using the keyboard (TAB, SHIFT TAB, and so on), by calling the Select or Select Next Control methods, or by setting the Container Control.Calling The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked.Let’s assume when we click our save button that we wish to validate the controls and display an icon if there is a problem.
Use this event to provide custom validation for any input control, such as a Text Box. In other words, the validating control will retain the focus until the user provides the correct format, even if the user clicks another control such as a button or textbox.This event occurs when the control is finished validating.Use this event to handle any needed upkeep after successfully validating the control.You can use a Windows Forms Error Provider component to display an error icon when the user enters invalid data.You must have at least two controls on the form in order to tab between them and thereby invoke the validation code.