Validation controls test user input, set an error state, and produce error messages. They do not change the flow of page processing — for example, they do not bypass your code if they detect a user input error. Instead, you test the state of the controls in your code before performing application-specific logic. If you detect an error, you prevent your own code from running; the page continues to process and is returned to the user with error messages.
You can test for a general, page-wide state, and you can test the state of individual controls. Typically, you do this in the event handlers that you create for a page.
Note Validation information is not available during a page's initialization or load stage. For details about page states, see Writing a Custom Web Forms Control.
To test for a general error state
The following example shows the event handler for a button. The code tests for valid user entries before proceeding to another step.
To test for the error state of individual controls
See Also
Validation Controls | Introduction to Validating User Input in Web Forms |