troubleshooting Question

Best practice for checking value of textbox against database 'on the fly'. (ASP.Net, VB)

Avatar of obiwankenobi
obiwankenobi asked on
ASP.NET
3 Comments1 Solution373 ViewsLast Modified:
Hi, people.

I have a rather general question but it would be nice if someone could come up with a really good solution with a code example that works....

My situation is quite simple, I have a texbox which is part of a larger webform to register new users in a system. Of course I do not want to get multiple users with the same username, so I would like to perform a check of this textbox as soon as the person making the registration leave the textbox .

Using my references I have come up with the following possible solutions, and would like to know what You guys have experience of being the most elegant one:

1. I can use a client-side Javascript triggered by the onBlur event. But then I have to 'pre-load' the data from the user database and fill an array or string to check against.

2. I can use the onChange event and then write a sub that perform a 'exists' query against the database. However, I guess I would then have to empty the value of the textbox or fill it with something that provokes the user to make another change (to get the onChange event to fire again after the postback). I would of course then also have a postback which causes a page reload.

3. I can use the Custom Validation control to perform a check either client-side or server side doing really the same thing as in the above examples.


I know that this question can be answered in a number of ways, and would encourage a discussion on what the most 'elegant' solution would be.

Regards,
Andreas
 

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros