Neudesic Blogs

Think Smart. Get Results.
Welcome to Neudesic Blogs Sign in | Join | Help
in Search

Pete Orologas

Extending .NET AjaxControlToolkit Autocomplete Control for Facebook Style Search

 

Problem: Give data-entry folks the ability to search through high schools in a quick and efficient manner.  The user should be able to search by high school name, city or zip and it should not to affect the user's productivity. Note: This is in a web-based environment.

 

Solution: Extend the existing AjaxControlToolkit autocomplete control to provide similar functionality to the Facebook’s search control.  See screen shots below.


Sample Solution and Source Code

Search By Name:

 

Search by Zip:

 

Search By City:

Add Watermark:

 

The solution fits all our clients’ criteria.

 

Fast:  The control is fast for a number of reasons. First off we are not rendering all the high schools on the client side.  Instead we are using Ajax calls to retrieve the list of high schools from a web-service.  Since the high school information in our database doesn't change very often we cache the results with an expiration (2 days) saving us time and saving the database effort.  Another reason the control performs very well is the fact that we only search when a user has typed 3 or more characters and we only return X number of results instead of every matching result.  If the user needs to further filter the results they simply add on another letter (or number depending on their search).

 

Productive: The autocomplete control is especially efficient for data-entry. Unlike a listbox or dropdown the user does not have to use the mouse to make a selection.  The user simply tabs into the textbox and begins typing.  This is not to say that a drop-down and a listbox don't have their own benefits but it's important to use the right control for the right purpose.  A listbox and a text box wouldn't be efficient because of the size of our dataset

 

Multiple Search Criteria:  Above we covered some limitations of dropdowns and listboxes but the main drawback for our requirements was the lack of multiple search criteria.  The autocomplete control gives us the ability to customize our searches anyway we see fit.

 

 

Please post comments and ideas.


Sample Solution and Source Code
*Please note that FireFox was not supported with this solution.

 

Pete Orologas

 

Published Tuesday, December 18, 2007 7:23 PM by Porologas

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

ASP.NET AJAX Toolkit Forum Posts said:

Guys, I came across an AutoComplete control on Pete Orologas's blog that does the searches like the facebook
December 18, 2007 3:01 PM
 

Rajiv said:

Hi,

  Looks very good from the screen shots.
  I would like to have the working code and play with it.

 I hope you wont mind sharing it.
 Please mail to rajiv.gowda@gmail.com

Rajiv
 
December 26, 2007 9:53 PM
 

m3ntat said:

Love it, I am building a Facebook application with asp.net and would love to use this to filter/find friends. Could I have access to this control.ascx/code?

I am sure loads of people have already made their own asp.net user controls they use in their Facebook applications, it would be great if we could get some sharing and reuse going on.

m3ntat@gmail.com

Thanks
January 7, 2008 7:25 AM
 

Jason said:

Hi,

Your extender looks fantastic especially the fact that you can get hold of the record ID, any chance of Firefox support in the future?


Jason
January 7, 2008 3:54 PM
 

Olavo Neto said:

Hi Pete! Fatastic Job!

About the firefox issue, just add

"padding-left:0px;" in the "autocomplete_completionListElement" style.

Best Regards

February 5, 2008 11:09 AM
 

Marc said:

In Firefox I am having issues aside from UI.  Upon selecting an entry, the textbox returns "undefined" (and the Javascript alert says Key: "undefined"). However, all the other values are correct.

Running Firefox version 2.0.0.12.  Anyone else see this issue?
February 22, 2008 9:13 AM
 

Alex said:

it does work with ie, it looks in the rigth way wit firefox, but after selected the item the function get_text() return 'undefined' and also in the textbox where the extender work on, instead of the selected text in firefox does show undefined as the popup that show key: undefined.

i can't find where it doesn't recognize the text. could you tell me if it can or not work with firefox? (v.2.0.0.13) in win vista...

thanks
April 7, 2008 5:58 AM
 

Вечерний макияж глаз фото said:

I not understend what U want
May 15, 2008 12:39 AM
 

Himmet Yelekin said:

if you change

       //won't work with the span tags we've added for style
       //var text = (item && item.firstChild) ? item.firstChild.nodeValue : null;
       var text = (item && item.firstChild) ? item.firstChild.innerText : null;

on _setText: function(item) {  property in the javascript file to this one

       switch(Sys.Browser.agent) {
           case Sys.Browser.InternetExplorer:
               var text = (item && item.firstChild) ? item.firstChild.innerText : null;
               break;
           default:  // Sys.Browser.Firefox, etc.
               var text = (item && item.firstChild) ? item.firstChild.textContent : null;
               break;
       }

it will work on firefox too. and some couple of css mistakes can be corrected by using the default syles.

and regards again it is a good solution.
May 19, 2008 6:15 AM
 

Dave C said:

Pete,
 In your sample I see highlighted text for the search term, how are you handling this?
June 6, 2008 7:39 AM
 

Sangram said:

This was pretty helpful!!!!!!!
June 30, 2008 4:16 PM
 

Halvo said:

Himmet,

The fix doesn't appear to work for me. Still getting undefined.

Has anyone else got this correctly working in FF or other browsers?

Halvo
July 28, 2008 10:05 AM
 

Halvo said:

Disregard the last comment about the fix not working, it works fine as long as you reference the newly compiled AjaxControlToolkit.dll from the client project.  Nice fix Himmet.

July 28, 2008 10:44 AM
 

Porologas said:

Hey guys, sorry for not getting back to your questions quicker but I've been promoted to Director of IT at Neudesic and I haven't been able to keep up on my blog. Here are some quick answers (as I remember some of the issues).

First off I didn't have to support firefox for my customer but here is what I believe will help.

Undefined:  This happens when you click in a "nether region".  Believe it or not this can be fixed in the stylesheet.  I believe you have to play around with the item padding...but I don't remember off hand. Check out Olavo's post, I think he's on the right track 

The second question I saw regarded the highlighting.  This is also done through the stylesheet.

I wasn't sure how many people were going to use this and I though the next rev of AJAX would have an autocomplete feature built in.  If you're using this in production I can crack the code open and make the fixes need....just let me know.

Pete Orologas
August 7, 2008 3:43 PM

What do you think?

(required) 
(optional)
(required) 

This Blog

Post Calendar

<December 2007>
SuMoTuWeThFrSa
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

Syndication

Powered by Community Server, by Telligent Systems