views:

4038

answers:

2

Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET webforms? If so, can anyone recommend a good method? From my reading so far, it seems like most people are using delimited lists rather than JSON to bring the items back. I'm open to any ideas that will get me up and running rather quickly.

+1  A: 

There are many, many examples on the web. I've used this one before, and if I recall you only need to create an aspx that will return matching terms as a <BR/> separated list:

http://www.dyve.net/jquery/?autocomplete

The documentation shows php in the example, but there's no difference in the way the plugin itself works and I didn't have to do anything special as a result.

From the documentation:

> $("#input_box").autocomplete("my_autocomplete_backend.php");

In the above example, Autocomplete expects an input element with the id "input_box" to exist. When a user starts typing in the input box, the autocompleter will request my_autocomplete_backend.php with a GET parameter named q that contains the current value of the input box. Let's assume that the user has typed "foo"(without quotes). Autocomplete will then request my_autocomplete_backend.php?q=foo.

The backend should output possible values for the autocompleter, each on a single line. Output cannot contain the pipe symbol "|", since that is considered a separator (more on that later).

An appropiate simple output would be: foo fool foot footloose foo fighters food fight

Pablo
I had run across this one before, but was just wondering if there were any other commonly used plugins. This one works great, though. Thanks for the input.
Mark Struzinski
+5  A: 

I made a tutorial to do this with asp.net mvc but it should be almost identical for traditional webforms:

http://blogs.msdn.com/joecar/archive/2009/01/08/autocomplete-with-asp-net-mvc-and-jquery.aspx