Export (0) Print
Expand All

Page.Validate Method

Instructs any validation controls included on the page to validate their assigned information.

[Visual Basic]
Public Overridable Sub Validate()
[C#]
public virtual void Validate();
[C++]
public: virtual void Validate();
[JScript]
public function Validate();

Remarks

This method is invoked when a user clicks any ASP.NET button server control that has the CausesValidation property set to true, which is the default. These include the Button, ImageButton, and LinkButton Web server controls and the HtmlInputButton, HtmlInputImage, and HtmlButton HTML server controls.

To disable validation for a page, or any button control on the page, set the button control's CausesValidation property to false.

When this method is invoked, it iterates through the validation controls contained in the ValidatorCollection object associated with the Page.Validators property and invokes the validation logic for each control.

Example

[Visual Basic, C#, JScript] The following example demonstrates calling the Validate method on a page when it is loaded, as long as the IsPostBack property returns false.

[Visual Basic] 
Sub Page_Load
    If Not IsPostBack
        ' Validate initially to force the asterisks
' to appear before the first roundtrip.
        Validate()
    End If
End Sub

[C#] 
void Page_Load() {
    if (!IsPostBack) {
        // Validate initially to force asterisks
// to appear before the first roundtrip.
        Validate();
    }
}

[JScript] 
function Page_Load() {
    if (!IsPostBack) {
        // Validate initially to force the asterisks
// to appear before the first roundtrip.
        Validate();
    }
}

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace | ValidatorCollection | Page.Validators

Show:
© 2014 Microsoft