tags:

views:

128

answers:

1

I have seen several websites nowadays that asynchronoulsy checks if the user name you are typing is available or not. It appears that they use AJAX for this (and capture the textbox on changed event and maybe call a server side method that does a DB call?)

For a ASP.NET/C# site, how would I go about doing this? I would really appreciate specific answers (and hopefully point me to an open source code that I could use to analyze the architecture of a website that does stuff like this?)

+3  A: 

Steps:

  1. Create a simple service to check availability of a username.

  2. Wire javascript to call the service when the text in the textbox on your page has changed.

  3. Call your simple service with the text in the textbox.

  4. Parse the result of your service call and render the alert on the page.

Justin Niessner
So, it appears that these websites use a service oriented architecture where most of the business logic is stored on a webservice?
The presence of a web service doesn't mean the site uses a Service Oriented Architecture. In the case of StackOverflow, the site uses an MVC architecture and probably has a few web services for simple AJAX operations.
Justin Niessner
So, does that mean any of the logic associated with the AJAX operation should be in the webservice? Generally, if there was a button that said "Check availability", I could write the logic in the code behind page (and can have access to viewstate and other control info). If the logic is in a WS, I don't have access to any of this stuff right?