Page.IsValid and the common rule 'don't relay on client-side validation only ... Validate server-side too'

using the asp.net validation controls doesn't not do all the job of the validation why because hackers simply can pass this validation from client side and go through your code directly and execute what they need with an invalid data :S

So it's very important to check the validation from server-side too , and this is the rule of Page.IsValid

Page.IsValid : Gets a value indicating whether page validation succeeded by iterating through all the page validation (or a certain validation group) and make sure that it's succeeded .

you should check this property after you have called the Page.Validate method.

Example for page validation

   1: Page.Validate();
   2: if(Page.IsValid)
   3: {
   4:     //do your logic here
   5: }

Example fro validating certain validation group :

   1: Page.Validate("ValidationGroupName");
   2: if(Page.IsValid)
   3: {
   4:     //do your logic here
   5: }

Enjoy:)

No Comments