Skip to main content

How to: Validate a Particular Editor

You can validate a specific editor in the following ways:

  • Set the ValidationSettings.ValidateOnLeave property to true (the default value) to automatically validate an editor after a user changes its value.
  • Call the editor’s client-side ASPxClientEdit.Validate method.

    <dx:ASPxLabel ID="lbl" runat="server" Text="E-mail:">
    </dx:ASPxLabel>
    <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" ClientInstanceName="tbEmail">
        <ValidationSettings ValidateOnLeave="False">
            <RequiredField ErrorText="E-mail is required" IsRequired="True" />
        </ValidationSettings>
    </dx:ASPxTextBox>
    <dx:ASPxButton ID="btn" runat="server" Text="Submit" AutoPostBack="False" CausesValidation="False">
        <ClientSideEvents Click="function(s, e) {
            tbEmail.Validate();
        }" />
    </dx:ASPxButton>
    
  • Call the editor’s server-side ASPxEdit.Validate method.

    <dx:ASPxLabel ID="lbl" runat="server" Text="E-mail:">
    </dx:ASPxLabel>
    <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px">
        <ValidationSettings ValidateOnLeave="False">
            <RequiredField ErrorText="E-mail is required" IsRequired="True" />
        </ValidationSettings>
    </dx:ASPxTextBox>
    <dx:ASPxButton ID="btn" runat="server" Text="Submit" onclick="btn_Click" CausesValidation="False">
    </dx:ASPxButton>
    
    protected void btn_Click(object sender, EventArgs e) {
        ASPxTextBox1.Validate();
    }