Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value indicating whether page validation succeeded.
public:
property bool IsValid { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsValid { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsValid : bool
Public ReadOnly Property IsValid As Boolean
true
if page validation succeeded; otherwise, false
.
The IsValid property is called before validation has occurred.
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."
private void ValidateBtn_Click(Object Sender, EventArgs E)
{
Page.Validate();
if (Page.IsValid)
lblOutput.Text = "Page is Valid!";
else
lblOutput.Text = "Some required fields are empty.";
}
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
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.
Product | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in