Overview

Username Availability Validator a.k.a UAV is normal validator control built with ASP.NET AJAX. It is used to validate the availablity of selected username in any data source using customized web service or page method.
The server control directly inherits from BaseValidator class & implements IScriptControl.
Inheriting from BaseValidator means that the control inherites all useful properties such ErrorMessage, Text, ValidationGroup, CssClass, Display etc...

Implemeting IScriptControl on the other hand defines methods that the control must implement to define resources in AJAX-enabled applications such as GetScriptDescriptors and GetScriptReferences.

Properties

ASPX Sample

<asp:TextBox ID="UserName" runat="server" />
<encosia:UsernameAvailabilityValidator 
     ControlToValidate="UserName" 
     CssClass="taken"
     Text="Username is taken"
     ErrorMessage="Username is taken"
     KeyPressDelay="500"
     MinimumLength="5" 
     ServiceMethod="IsUsernameAvailable"
     ServicePath="~/MembershipService.asmx"
     ValidateOnKeyPress="True"
     runat="server"/>

Web Service Sample

The following Code snippet defines the service with its method that is used to identify if the username is available or not.
using System.Web.Services;
using System.Web.Script.Services;

[ScriptService]
public class MembershipService : System.Web.Services.WebService
{
    [WebMethod]
    public bool IsUsernameAvailable(string username)
    {
        //Check if username Available using basic ASP.NET Membership Provider Service
        return System.Web.Security.Membership.GetUser(username) == null;        
    }
}

Blog Posts

Live Demos