Username Availability Validator AJAX Control, Release Demo

by mosessaur| 04 January 2009| 9 Comments

Back in September last year (2008), I posted a demo about Username Availability Validator Control. This control developed by the community on a contest initiated by Dave Ward on August 2008 as I remember. At that time the control was in beta.

On October 2008 the control was released to public on its first version. And finally I wrote a a very simple documentation on the project Wiki.

In this post I am going to update my previous demo as well as provide new feature on the control which is SuccessMessage property to be displayed if the Username is available. This update is not available so far on project at CodePlex. This is a private update which I provided on this post only. [View Demo]

In my previous post about this subject someone asked how to apply styles similar to the ones provided by Dave himself on his post "ASP.NET AJAX username availability check". It was pretty simple to apply it using Style Sheets. Here is the updated markup of the control to use CssClass property:

<encosia:UsernameAvailabilityValidator 
	ControlToValidate="UserName"
	ValidationGroup="CreateUserWizard"
	CssClass="taken"
	ErrorMessage="Taken"
	KeyPressDelay="500"
	MinimumLength="5" 
	ServiceMethod="IsUsernameAvailable"
	ServicePath="~/MembershipService.asmx"
	ValidateOnKeyPress="True"
	Display="Static"
	runat="server"/>

As you noticed on line 4 I set CssClass property to 'taken', here is the style for the 'taken' CssClass:
.taken
{
    padding-left:22px;
    padding-bottom:3px;
    background-repeat:no-repeat;
    background-image: url(../img/taken.gif);
    color:Red;
}

What I want to show here is that it is as simple as creating Style Sheet and set a background-image property and configure it properly.

As I mentioned earlier, I updated the control to implement SuccessMessage property with SuccessCssClass. We discussed SuccessMessage & SuccessCssClass on the project discussion but they were taken off before the release of the first version. And so I decided to try it personally and gain feedback before merge it to the project original source code. I had to override the basic Render method of the server control to have more control over the rendered HTML and provide another span to display SuccessMessage and apply SuccessCssClass

You can view the demo to see this working in real life example.

<encosia:UsernameAvailabilityValidator 
	ControlToValidate="UserName"
	ValidationGroup="CreateUserWizard"
	CssClass="taken"
	SuccessCssClass="available"
	Text="Taken"
	ErrorMessage="Taken"
	SuccessMessage="Available"
	KeyPressDelay="500"
	MinimumLength="5" 
	ServiceMethod="IsUsernameAvailable"
	ServicePath="~/MembershipService.asmx"
	ValidateOnKeyPress="True"
	Display="Static"
	runat="server"/>

You can download the full solution to explore the code. Hopefully soon it will be added to the original project source control. Mainly I updated both Server Control & Client Control to manage showing and hiding ErrorMessage or SuccessMessage.

kick it on DotNetKicks.com

Comments (9) -

Webio
Webio Poland on 12/27/2008 8:40 AM Hello!

Thanks for this control. If I may I will write about about some issues I had with previous version. Can you add checking if textbox has been changes without using keyboard? Sometimes user have stored autocomplete usernames in their browsers so they doubleclick on empty field and choose previously used usernames which is not firing validation.

I can show you other scenario when validation will not fire:
1. Open mosesofegypt.net/.../CreateUser.aspx
2. Enter "encosia" in username field and fill all other fields but instead of submitting press F5 to refresh page. In Firefox 3 Username will be filled with "encosia" so validator will not check for this username because user didnt used his keyboard. So maybe solution to resolve this issue could be checking for username if textbox is not empty after loading page.

Thanks
Sergejus
Sergejus Lithuania on 12/27/2008 9:02 AM I really encourage you to rename this plugin to something like RemoteExistanceValidator, because it can be easily used not only to validate existance of username, but existance of emails and other stuff. I can imagine using it even to validae whether specified City name exists.

Anyway, great work!
redsquare
redsquare United States on 12/27/2008 12:33 PM Oh how I mess the joys of webforms especially this for example

CreateUserWizard_CreateUserStepContainer_UsernameAvailabilityValidator1

Not........Smile
mosessaur
mosessaur Egypt on 12/27/2008 10:17 PM @[Webio] thank you so much for your feedback. You are right, also we recognize that some features like copy\paste & drag\drop do not fire validation as well. We will try to find a way to resolve this. However if you click on create user button on your case, the validation will fire! and will block the.

@[Sergejus] Good idea, I totally recognize that too. It can be used in different way, Maybe Dave would change it someday Smile

@[redsquare] I don't understand what you mean!
Janko
Janko Serbia on 12/28/2008 12:25 AM Great work, man!
DotnetShadow
DotnetShadow Australia on 1/5/2009 2:32 AM Hi there,

Great control, I was testing out your control and found that it doesn't handle the case when you enter username that needs to be of at least a certain length. For example in your demo if you type encosia it will return "Taken" if you delete all the text then tab to a new field it still shows the word "Taken" with a * next to it.

Ideally we would need a minimum length a username property which will show minimumlength message or something?

What are your thoughts on this? How can this be fixed?

Regards DotnetShadow
mosessaur
mosessaur Egypt on 1/5/2009 4:58 AM @DotnetShadow In the control discussion forum http://www.codeplex.com/UsernameAvailability we discussed many things including what you have mentioned in your comment. But not everything were implemented due to time limitation I guess, even the SuccessMessage with SuccessCssClass were not implemented at that time.
I think we might invest more time to add enhanced features to this control later
shrage
shrage United States on 1/6/2009 9:08 PM I want to attach a javascript function so it gets called every time the validation has completed, how do i do it?
animemanga
animemanga on 1/11/2009 11:31 PM Great work, man! Thanks for code

Pingbacks and trackbacks (4)+

Comments are closed