Click here to Skip to main content
14,384,168 members
Rate this:
Please Sign up or sign in to vote.
See more:
if (Page.IsValid)
                lblTxt.Text = "Page is Valid";
                lblTxt.Text = "Page is not Valid";

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
Monjurul Habib 8-May-12 16:36pm

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100