Page.IsValid And Page.Validate in Asp.net

Here we will see the use of Page.IsValid and Page.Validate in Asp.net.

Suppose we have a login form with two text box(username and password) and a submit button and we have to validate the user input before submitting to server so that only valid data goes to server.

We can achieve this by applying client side validations but always remember that the client side validations are not secure as a hacker can disable the javascript and bypass our validations. Here is where the Page.Validate() method and Page.IsValid property comes into play.

The Page.Validate() method is fired automatically by controls that have the CausesValidation property set to true. Note that the Button control’s CausesValidation property is true by default.

The code is as follows: Continue reading Page.IsValid And Page.Validate in Asp.net

Advertisements