jQuery autocomplete in ASP.NET webforms?

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

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

Method 3

I wrote an Asp.Net WebControl and some Asp.Net MVC extension methods wrapping the JQuery UI autocomplete widget.

I wrote documentation as well about how to implement a working resource providing a JSon result.

You can find it at:

http://autocompletedotnet.codeplex.com/

Hope it can help


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x