How server-side validation works in ASP.NET 4.0

You can use the validator controls, described in the article How validation controls work in ASP.NET 4.0,  to verify a page automatically when the user submits it or manually in your code. The first approach is the most common. When using automatic validation, the user receives a normal page and begins to fill in the input controls. When finished, the user clicks a button to submit the page. Every button has a CausesValidation property, which can be set to true or false. In addition many other button-like controls, like LinkButton, ImageButton, and BulletedList, that can be used to submit the page also provide the CausesValidation property. What happens when the user clicks the button depends on the value of the CausesValidation property:

–  If CausesValidation is true (the default), ASP.NET 4.0 will automatically validate the page when the end user clicks the button. It does this by performing the validation for each control on the page. If any control fails to validate, ASP.NET 4.0  will return the page with some error information, depending on your settings. Your click event handling code may or may not be executed—meaning you’ll have to specifically check in the event handler whether the page is valid.

–  If CausesValidation is false, ASP.NET 4.0  will ignore the validation controls, the page will be posted back, and your event handling code will run normally.

In other words that validation happens automatically when certain buttons are clicked. It doesn’t happen when the page is posted back because of a change event (such as choosing a new value in an AutoPostBack list) or if the user clicks a button that has CausesValidation set to false. However, you can still validate one or more controls manually and then make a decision in your code based on the results.