posted on Thursday, June 08, 2006 1:28 AM
by
thomasswilliams
Autocompletion ASP.NET Control
There are many auto-complete/auto-suggest web controls around, and when I needed AJAX functionality to get the data from the server dynamically, in preferably an ASP.NET control, I started using the excellent "Implementing an Ajax.NET-based Lookup Server Control" on CodeProject.
This is a nice control that works in with AJAX.NET and has many configurable properties. Unlike some of the other similar controls I've found, it also supports keyboard selection of the returned matches (using the up and down arrow keys). And, since it uses AJAX.NET, it can take advantage of Session variables (should you need them). All this is packaged into a replacement control for the standard textbox.
Unfortunately it's beyond me to get more than one of these controls working on the same page - doing this would require some serious javascript kung-fu which I do not possess. So, I did some research and eventually settled on SimoneB's ASP.NET wrapper of the script.aculo.us autocompletion control.
SimoneB has done a fine job - using her sample video, I was up and running in a couple of minutes, and I could use multiple controls on the same page. Also, script.aculo.us brings some nice javascript-based animation into the bargain and SimoneB has made it easy to add a "loading" GIF too. Keyboard support is still there, but unfortunately I can't seem to find how to use ASP.NET Session vvariables (no matter, this can be worked around). Although I believe the script.aculo.us control does cache data, it's not quite as configurable as with AJAX.NET.
One other criteria was that the control by quick to implement. I had a limited window which prevented deep research, in-house development or even the possible purchase of a more fully-functioned control.
Some other alternatives that I have not personally used, but look promising, include GoogleSuggestCloneJax, AJAX.NET sample, AutoSuggestBox, capxous ($), CPAN Suggest, EBA: Web ComboBox V3 ($) and BComplete.
Out of all of these controls, BComplete looks interesting because it overcomes the problems of a lot of items being returned by providing a top and bottom scroll section (most of the other controls take the approach that they'll only return up to 10 or so items, so the rest of the matches aren't unviewable off the page). I lessened the impact for my users by matching after they'd typed at least two characters, which makes business sense in my situation.
Overall the new control is far better in my situation than the standard ASP.NET drop-down, to allow users to type and have auto-suggest, as opposed to only being able to select from a list. Also, page size is reduced because all the options don't have to be pre-loaded.
Tags: asp.net, auto-complete, auto-suggest, javascript, ajax
Update June 14th 2006: Ryan Homer has extended and improved the autocomplete control on CodeProject (not looked at, but might be helpful) to allow multiple instances.