asp.net.ph

Page.IsValid Property

System.Web.UI Namespace   Page Class


Returns a value indicating whether page validation succeeded.

Syntax


Script [ bool variable = ] Page.IsValid

Property Value

This property returns only a boolean value: true if page validation succeeds; otherwise, false.

The property is read only with no default value.

Remarks

For this property to return true, all validation server controls in the Page.Validators property must validate successfully.

This property should be checked only

  • after the Page.Validate method has been called, or
  • the CausesValidation property is set to true in the ServerClick handler for an ASP.NET server control that initiates form processing.

The server controls that can be used to post a form for processing include the Button, HtmlButton, HtmlInputButton, HtmlInputImage, ImageButton, and LinkButton classes.

This property is typically used within a button click event handler to conditionally execute one or more embedded statements, depending on whether page validation succeeded or not.

IsValid can also be used within a Page_Load event handler that includes a Page.IsPostBack check. In a page with validation controls, this property is set after all validation controls have been processed. If any of the controls reveals that a validation check has failed, the entire page is set to invalid.

Example

The below snippet illustrates using the IsValid property.

void chkFirst ( object src, EventArgs e ) {
   if ( Page.IsValid ) {
      // ... do something
   } else (
      // ... do otherwise
   }
}
  C# VB

 Show me 

See Also

Page Members   Web Forms Validation Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph