Page.IsValid Property
Definition
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
Property Value
true
if page validation succeeded; otherwise, false
.
- Attributes
Exceptions
The IsValid property is called before validation has occurred.
Examples
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 == true)
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
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기