Finally.. after many modifications, the AJAX AutoComplete for ASP.NET 2.0 web user control is available for download.  This web control contains a text box. As you type in the box, suggestions fill in a drop down, very similar to Google Suggest. 

There are many configuration options, so if you are looking for a quick fix, you shouldn't have to get your hands too dirty.  On the other hand if you're looking for a base to build on, all of the C# and javascript code is included - hack away to your heart's content. If you make something cool, leave a comment and let me know about it. 

The styling for all of the components is done with CSS contained in an external file.  All you need to do is set the control's properties to the class names for each element.  There are other display options, optional features like AutoPostBack, case-sensitivity, server-side caching and other search options as well.  For more information on what you can do, read the documentation.

Or if you're one of those people who are more of a hands-on learner, you can play with the demo which is also included in the .zip file.

Download the Visual Studio 2005 Solution .zip file (18k)

I designed this control to be very easy to use, however it does assume you have a working knowledge of ASP.NET.  I will do my best to answer any questions, but the software is offered with no guarantees.


If you liked this post, please be sure to subscribe to my RSS Feed.



I've noticed over the past few days that I've been getting a lot of hits on the AJAX Autocomplete post I made, so I've decided to package up what I've done into a downloadable and reusable user control.  At the moment, I'm taking a lot of the options I had hardcoded (case sensitivity, whether it autocompletes based on "Starts with" or "Contains") and creating them as Parameters.

Check back soon for an update or better yet, subscribe to the RSS feed to know when it's been released.

EDIT:  It is now available - More Information

 


If you liked this post, please be sure to subscribe to my RSS Feed.


Edit: 4/12/06

I'm going to make this available as a download as soon as I have it cleaned up.  See here for more details.

Edit: 4/21/06: It is now available - More Information

Tonight, I was able to get my category AutoComplete feature working using AJAX in ASP.NET.  I have a query text box that fill the matching categories into a textbox as you type, similar in idea to Google Suggest.

Here's how it works..

As you type, the onKeyPress event is triggered, sending the query back to the server in the background.  On the first call of the page, it checks the Cache to see if the category list is already loaded.  If not, it goes out to the database and loads it into a Generic List object and then saves that object into Cache.  If it is located in Cache, it just grabs the Cache Item, casts it to List<string> and uses that.

Then I take what the user has typed so far and use List.FindAll() to find all matching values. Since it's coming out of memory most of the time, it's pretty fast.  There also aren't many categories, so even when it needs to go out to the database, it doesn't take too much time. Once it has all of the matching values, they are concatenated with commas and sent back to the client side.

The Javascript then takes that string, splits it along the commas and adds a new line to the textbox.


function fillAutoComplete(result, context) {
    fields=result.split(',');
    var txtAutoComplete = getObj('AutoComplete');
    txtAutoComplete.obj.value='';
    for (var i=0; i<fields.length; i++) {
        txtAutoComplete.obj.value += fields[i]+'\n';
   }
}

Currently, I have it just filling a textbox for test purposes, but eventually, it will be in a clickable dropdown.  The key to this is making it easy for the user to select a category of food to either add to their daily diet tracking or for the classification of custom foods.  This UI interface is a great blend of browsing and searching.  As you type, a search is performed which progressively limits the items you have to browse through.

It's coming along.. slowly, but surely.


If you liked this post, please be sure to subscribe to my RSS Feed.



Subscribe

About the author

Wayne Hunt I am a web application developer and second degree black belt living in Providence, RI.

More about Me..

E-mail me Send mail

Other blogs

Dugg Sites

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008

Sign in