Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Page Class
Page Properties
 IsValid Property
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Page..::.IsValid Property

Updated: November 2007

Gets a value indicating whether page validation succeeded.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public ReadOnly Property IsValid As Boolean
Visual Basic (Usage)
Dim instance As Page
Dim value As Boolean

value = instance.IsValid
C#
[BrowsableAttribute(false)]
public bool IsValid { get; }
Visual C++
[BrowsableAttribute(false)]
public:
property bool IsValid {
    bool get ();
}
J#
/** @property */
/** @attribute BrowsableAttribute(false) */
public boolean get_IsValid()
JScript
public function get IsValid () : boolean

Property Value

Type: System..::.Boolean

true if page validation succeeded; otherwise, false.

ExceptionCondition
HttpException

The IsValid property is called before validation has occurred.

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.

TopicLocation
How to: Disable Validation for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Disable Validation for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Disable Validation for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Display Server Side Custom Validation Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Display Server Side Custom Validation Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Display Server Side Custom Validation Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Format Validation Error Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Format Validation Error Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Format Validation Error Messages for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Specify Layout for In-Place Messages On ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Specify Layout for In-Place Messages On ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Specify Layout for In-Place Messages On ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Test Validity Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Test Validity Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Test Validity Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Against a Data Type for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Data Type for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Data Type for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Against a Range of Values for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Range of Values for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Range of Values for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Against a Specific Value for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Specific Value for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against a Specific Value for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Against Patterns for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against Patterns for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against Patterns for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Against Values in a Database for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against Values in a Database for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Against Values in a Database for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Programmatically for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate Required Entries for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Required Entries for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate Required Entries for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
How to: Validate with a Custom Function for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate with a Custom Function for ASP.NET Server ControlsBuilding ASP .NET Web Applications
How to: Validate with a Custom Function for ASP.NET Server ControlsBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Validating User Input in a Web Forms PageBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Validating User Input in a Web Forms PageBuilding Applications with Visual Web Developer

The following code example demonstrates using the IsValid property to set up a conditional statement. If the property returns true, the Text property of the lblOutput control is set to "Page is valid!" Otherwise, it is set to "Some of the required fields are empty."

Visual Basic
Sub ValidateBtn_Click(sender As Object, e As EventArgs)
    Page.Validate()
    If (Page.IsValid) Then
        lblOutput.Text = "Page is Valid!"
    Else
        lblOutput.Text = "Some required fields are empty."
    End If
End Sub

C#
private void ValidateBtn_Click(Object Sender, EventArgs E)
{
    Page.Validate();
    if (Page.IsValid == true)
        lblOutput.Text = "Page is Valid!";
    else
        lblOutput.Text = "Some required fields are empty.";
}

J#
void ValidateBtn_Click(Object sender, EventArgs e)
{
    this.get_Page().Validate();
    if (this.get_Page().get_IsValid() == true)
        lblOutput.set_Text("Page is Valid!");
    else
        lblOutput.set_Text("Some of the required fields are empty.");
}

JScript
function ValidateBtn_Click(Sender, e : EventArgs) 
{
    Page.Validate();
    if (Page.IsValid == true) 
        lblOutput.Text = "Page is Valid!";
    else
        lblOutput.Text = "Some required fields are empty";
}

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker