When to use Page.IsValid ?
Posted by archworx on May 15, 2007
In his asp.net blog http://weblogs.asp.net/sibrahim/archive/2003/06/15/8723.aspx, Samer Ibrahim points out a very important issue regarding Page.IsValid usage in asp.net pages. He quoted the following paragraph from Fritz Onion’s book ‘Essential asp.net’ :
“As soon as you place a validation control on a page, it is imperative that you check the IsValid flag of the Page class before using any of the data posted by the client. It is a common misconception that if validation fails on a page, the code for that page will not execute. On the contrary, the only thing that happens when server-side validation fails is that the IsValid flag of the Page class is set to false, and each validation control that failed renters itself as a visible span so that the error indicator shows up when the page is redisplayed to the user.”