Download Now Code Base AsyncDocs Contact Us
asyncValidator
liveDemo
This demo uses mulitple validation attached to one AsyncTextBox.

Enter a bad date (ex: 0/0/002) to test the compare validation, and enter nothing then click "Validate" to test the required field validation.

Multi-Validation (Date/Required Field)

This demo uses a single AsyncValidator in conjuction with the AsyncTextBox internal validator.

Enter any letters into the text box to test the compare validation, and leave the field blank then click "Validate" to test the AsyncTextBox internal validation.

Compare Validator (w/ Internal Required Field)

This demo uses a AsyncValidator.

Leave the text box blank then click "Validate" to test the required field validation.

Required Field Validator

This demo uses a single AsyncValidator.

Enter a value greater than 150 to test the range validator.

Range Validator

This demo uses a single AsyncValidator in conjuction with the AsyncTextBox internal validator.

  • Enter anything other than the word "AsyncControls" to test the regular expression.
  • The regular expression AsyncValidator exposes IgnoreCase, meaning the regular expression will match regardless of the input casing.
  • Leave the text box blank to test the AsyncTextBox internal validator.
Regular Expression Validator (w/Internal Required Field)

This AsyncValidator supports RegexOptions, such as IgnoreCase, Multiline, etc.

Type AsyncControls (case-insensitive):

This demo uses a single AsyncValidator.
  • Leave the dropdown in its default position (nothing selected) to test the AsyncListControl validation.
  • Selecting any other list item will validate the AsyncValidator.
AsyncListControl Validator

  • Click "Validate All" to test the validation of all the AsyncValidators on this page.
  • If any validation fails it logged in the AsyncPage ValidatorCollection and then displayed using the message box (this behavior can be customized).
  • The above "Validate" buttons were inside of an AsyncPanel so they only caused validation on its sibling controls (Strict validation).

Test validation.

Description

The AsyncValidator is a Async-Enhanced "one size fits all" validator server control. It has every type of validation currently available, built-in to this one control.



Features
  • Combines all available validation types into this one control. This one control can validate an AsyncListControl or an AsyncTextBox.
  • Reference or ID based validation. Even if the control you want to validate cannot be validated by ID you can instead assign its reference.
  • Can be scrolled into view during an AsyncCallback.
  • Change the visibility, CSS class, and ForeColor/BackColor, during an AsyncCallback.
  • Regular expression validation supports multi-line, case-insensitivity, and more.
   
<%@ Register Assembly="AsyncControls" Namespace="DelvingWare.AsyncControls" TagPrefix="dw" %>

<dw:AsyncPanel runat="server" ID="pnlOne" CssClass="liveDemoSectionDiv">

    <div class="liveDemoSectionTitle">Multi-Validation (Date/Required Field)</div>
    <dw:AsyncTextBox ID='txtMain' runat="server" CssClass="forms" />
    
    <dw:AsyncButton runat="server" ID="btOne"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>

    <br />
    
    <dw:AsyncValidator ID="txtV" runat="server" 
        ControlToValidate="txtMain"
        ErrorMessage="Please enter a date. " 
        ErrorMessageCssClass="errorMsg" />
        
    <dw:AsyncValidator id="txtV2" runat="server"
        ControlToValidate="txtMain"
        ErrorMessage="Please enter a valid date." 
        ErrorMessageCssClass="errorMsg" 
        Operator="dataTypeCheck"
        Type=Date Validation="Compare" />
        
</dw:AsyncPanel>

<dw:AsyncPanel runat="server" ID="pnlTwo" CssClass="liveDemoSectionDiv">
    <div class="liveDemoSectionTitle">Compare Validator (w/ Internal Required Field)</div>
    <dw:AsyncTextBox runat="server" ID="txtCmp"
    ErrorMessageCssClass="errorMsg"
    ErrorMessage="Required Field"
    EnableValidation="Enabled" />
    
    <dw:AsyncButton runat="server" ID="btTwo"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>
    
    <br />
    
    <dw:AsyncValidator runat="server" ID="cmpV"
    ControlToValidate="txtCmp"
    ErrorMessage="Numbers only."
    ErrorMessageCssClass="errorMsg"
    Operator="DataTypeCheck"
    Type="Integer" 
    Validation="Compare" />
    
</dw:AsyncPanel>

<dw:AsyncPanel runat="server" ID="pnlThree" CssClass="liveDemoSectionDiv">
<div class="liveDemoSectionTitle">Required Field Validator</div>
    
    <dw:AsyncTextBox runat="server" ID="txtReqField" />
    
    <dw:AsyncButton runat="server" ID="btThree"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>
    <br />
    
    <!-- It performs Required Field validation by default -->
    <dw:AsyncValidator runat="server" ID="reqFieldV"
    ControlToValidate="txtReqField"
    ErrorMessageCssClass="errorMsg">Required field.</dw:AsyncValidator>
    
</dw:AsyncPanel>

<dw:AsyncPanel runat="server" ID="pnlFour" CssClass="liveDemoSectionDiv">
<div class="liveDemoSectionTitle">Range Validator</div>
    
    <dw:AsyncTextBox runat="server" ID="txtRange" />
    
    <dw:AsyncButton runat="server" ID="btFour"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>
    <br />
    
    <dw:AsyncValidator runat="server" ID="rangeV"
    ControlToValidate="txtRange"
    ErrorMessageCssClass="errorMsg"
    MinimumValue="100"
    MaximumValue="150"
    Validation="Range">Value must be between <b>100</b> and <b>150.</b></dw:AsyncValidator>
    
</dw:AsyncPanel>

<dw:AsyncPanel runat="server" ID="pnlFive" CssClass="liveDemoSectionDiv">
<div class="liveDemoSectionTitle">Regular Expression Validator (w/Internal Required Field)</div>

    <p style="font-family: Trebuchet MS, Arial; font-size: 10pt;">
    This AsyncValidator supports RegexOptions, such as IgnoreCase, Multiline, etc. 
    </p>
    
    Type <b>AsyncControls</b> (case-insensitive): 
    <br />
    <dw:AsyncTextBox runat="server" ID="txtRegex"
    EnableValidation="Enabled"
    ErrorMessage="Required Field"
    ErrorMessageCssClass="errorMsg" />
    
    <dw:AsyncButton runat="server" ID="btFive"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>
    <br />
    
    <dw:AsyncValidator runat="server" ID="regexV"
    ControlToValidate="txtRegex"
    ErrorMessageCssClass="errorMsg"
    ValidationExpression="asynccontrols"
    ValidationExpressionOptions="IgnoreCase"
    Validation="RegularExpression">Please type: AsyncControls.</dw:AsyncValidator>

</dw:AsyncPanel>

<dw:AsyncPanel runat="server" ID="pnlSix" CssClass="liveDemoSectionDiv">
<div class="liveDemoSectionTitle">AsyncListControl Validator</div>
    
    <dw:AsyncDropDownList runat="server" ID="drpList">
        <dw:AsyncListItem Value="none" />
        <dw:AsyncListItem Value="one">One</dw:AsyncListItem>
        <dw:AsyncListItem Value="two">Two</dw:AsyncListItem>
    </dw:AsyncDropDownList>
    
    <dw:AsyncButton runat="server" ID="btSix"
    CausesStrictValidation="true"
    CssClass="greyButton">Validate</dw:AsyncButton>
    <br />
    
    <dw:AsyncValidator runat="server" ID="drpV"
    ControlToValidate="drpList"
    ErrorMessage="Please select a valid list item."
    ErrorMessageCssClass="errorMsg"
    InitialValue="none" />

</dw:AsyncPanel>

<dw:AsyncLabel runat="server" ID="lblMain" 
RenderMode="paragraph">Test validation.</dw:AsyncLabel>

<dw:AsyncButton runat="server" ID="btMain" 
CausesValidation="true" 
OnClick="btMain_Click"
CssClass="greyButton">Validate All</dw:AsyncButton>