Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (Page.IsValid)
            {
                lblTxt.Text = "Page is Valid";
            }
            else
            {
                lblTxt.Text = "Page is not Valid";
            }
Posted

1 solution

From MSDN[^]:

"For this property to return true, all validation server controls in the current validation group must validate successfully. You should check this property only after you have called the Page.Validate method, or set the CausesValidation property to true in the OnServerClick event handler for an ASP.NET server control that initiates form processing. These server controls include the Button, HtmlButton, HtmlInputButton, HtmlInputImage, ImageButton, and LinkButton classes.

If you force validation of a validation group using the Validate method, then all validation controls in the specified validation group must validate successfully as well."


So, if you want to know if your validation worked, check the property.
 
Share this answer
 
Comments
Monjurul Habib 8-May-12 16:36pm    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900