Username Availability Validator
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
on the other hand defines methods that the control must implement to define resources in AJAX-enabled applications such as GetScriptDescriptors
- ServicePath: Path of the web service that is responsible to check for UserName availability. Checkout Communication Method thread in discussion
- ServiceMethod: Name of the web method in the web service specified in ServicePath that is responsible for performing the logic to check for UserName availability. It is called when the validation process starts. This method must accept one parameter string called "username" and returns a boolean value. Checkout Communication Method thread in discussion
- MinimumLength: Gets or sets a value indicating minimum number of characters in UserName before validation process take place.
- ValidateOnKeyPress: A boolean value that indicates whether the validation process should take place upon keypress or not.
- KeyPressDelay: Gets and sets a value indicating how long after keyup validation happens. Only has effect with ValidateOnKeyPress is set to true.
<asp:TextBox ID="UserName" runat="server" />
Text="Username is taken"
ErrorMessage="Username is taken"
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.
public class MembershipService : System.Web.Services.WebService
public bool IsUsernameAvailable(string username)
//Check if username Available using basic ASP.NET Membership Provider Service
return System.Web.Security.Membership.GetUser(username) == null;