views:

265

answers:

5

I am using asp.net C# 2008, and I need to create a search textbox which will display dropdown values (similar to google search); The values displayed in the dropdown will be values from the SQL 2005 database (example the user is searching on FirstName, the dropwdown will display all firstnames, which get filtered as the user types in more letters.... if user is searching on LastName, the dropdown displays all LastName values in the database.. etc)

Any ideas how to go about this task?

+5  A: 

You're looking for an Auto Complete behavior for you text box. i suggest using a ready jQuery plugin solution.

http://docs.jquery.com/Plugins/Autocomplete

Mendy
This is the solution I used for this instance - implimented in client with a c# back end returning the JSON object list. +1
Mark Schultheiss
A: 

javascript is your answer. about 150ms after a key stroke, send a request to your web site for the matching values. Just be prepared to discard it if the user types another letter. Very little value in trying to respond after every keystroke.

No Refunds No Returns
A: 

There's no built in server control for this. You should implement your own.

Take a look at JQuery AutoComplete plug in and try to implement it with Ajax callbacks.

Canavar
+1  A: 

This is solution specific to ASP.NET. Microsoft implemented this in Ajax Control Toolkit (AutoComplete control). Here's working example:

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx

But make sure you understand how it works inside (using Ajax calls), don't just use control blindly.

Vitaly
The ajax control in the link above is quite slow (compared to the google website);
user279521
There're few reasons for that. There's a certain overhead from Ajax Control Toolkit, so you pay for simplicity of use by slowness of MS code. And also speed depends on server settings, algorithm, caching etc. You can't just compare by a first look.
Vitaly
+1  A: 

I would recommend checking out the ASP.NET AJAX Control Toolkit's implementation if the AutoComplete control. The once the toolkit is installed you can extend the standard ASP WebForm TextBox control to use it.

Kit Roed