Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

carlosbutler

macrumors 6502a
Original poster
Feb 24, 2008
691
2
I would like to create an autocomplete search box, that is able to display a list of things, like Google for example, when you start to type.

Two main things I cant really work out:
1) Do I constantly search through the database each time a new letter is typed in or load all the values (only about 100) in to an array on page load?

2) Any way of doing this just in ASP.net technologies?

I would also like to use MooTools, so if anyone has any suggestions please let me know.
 
There are not to many ASP.net devs around here but from your requirements your wanting to,

Hold the search until maybe more than 3 characters have been entered - this will limit the strain on the database.

The search would be done via AJAX you can use bog standard AJAX for this or any number of frameworks though i have no experience in any of the frameworks as of yet.

The AJAX call is to the ASP.net page so the actual client side call is the same Javascript regardless of backend language.

Creating a stored search procedure on the SQL database will further help make it language agnostic.

In this SQL procedure or your SQL query set a LIMIT! - If your database has 10,000,000 records that is a lot of records to be returned if the user input is "the" or another common word.

For the auto completion part your just returning a value back to the input box your using for searching.

I used http://www.w3schools.com/ajax/ajax_database.asp as a starting point for my own search script, replacing the drop down box with a search field and changing some code about where needed.

Hope this helps you get on the right track.
 
Yeah thanks. I ended up using a MooTools built in function to output and allow autocompletion.

The search data, well that is less than 100 records in this case, so I just stored it in a JavaScript array. This was deliberate, as all the information being output from the database is publicly available anyway. I also had to do this, as a lot of the search things would only be three or four characters long, so I would need to start the search from the first letter typed in.

I think I will try and implement one that reads from the database each time you press another button.
 
And yes, I guessed their wouldn't be that many ASP.net developers. I only had to use it for an internal University web app. If you are a developer reading this, give ASP.net a try, it's not as crap as I thought it was and does quite a few useful things. The only down side is it's Windows only development, and only runs on Windows IIS servers.
 
And yes, I guessed their wouldn't be that many ASP.net developers. I only had to use it for an internal University web app. If you are a developer reading this, give ASP.net a try, it's not as crap as I thought it was and does quite a few useful things. The only down side is it's Windows only development, and only runs on Windows IIS servers.

Yep ASP.net is pretty good but so limited in development and deployment options. As a language designed to take on Java, Microsoft really missed the boat. Java can be deployed anywhere and developed on any platform while ASP.net can only be run on Windows servers and developed using Visual Studio which is only available on Windows.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.