System.Web.UI Namespace Page Class
Returns a value indicating whether page validation succeeded.
Script |
[ bool variable = ] Page.IsValid |
This property returns only a boolean value: true if page validation succeeds; otherwise, false.
The property is read only with no default value.
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.
The below snippet illustrates using the IsValid property.
void chkFirst ( object src, EventArgs e ) {
if ( Page.IsValid ) {
// ... do something
} else (
// ... do otherwise
}
}
Sub chkFirst ( sender As Object, e As EventArgs )
If Page.IsValid Then
' ... do something
Else
' ... do otherwise
End If
End Sub |
|
C# |
VB |
Show me
Page Members Web Forms Validation