views:

2509

answers:

5

how do i make an autocomplete textbox in asp? but i need to get the autocomplete data by querying the database. I dont really know how to explain this, sory if theres not enough detail. i cant use ajax, because i think i will have compability issues with my old app. so im thinking of doing this using java script. or is there a way to do this by using .net? im using C# for codebehind. thanks

+3  A: 

It's going to be a lot of effort without using some third party autocomplete I think - not sure what you mean by 'I can't use ajax', but how about using the ASP.NET AJAX autocomplete control, setting the ServiceMethod property to a static Page Method in your code behind? That keeps it contained within your page at least.

The Page Method can go off to your database, and return a String[] of results.

If you decide to use it, you'll need to set the EnablePageMethods property to true in the <asp:ScriptManager> control.

Phil Jenkins
+1  A: 

AJAX is JavaScript. It's JavaScript using the XMLHttpRequest object to make the asynchronous request. Here's an article about it and ASP.NET.

If you want to know more about AJAX, (Asynchronous JavaScript and XML), I'd check out Wikipedia first. If you want books on it, there are a ton. I recommend Programming ASP.NET AJAX by Christian Wenz (O'Reilly And Associates).

George Stocker
A: 

will ajax work on visual studio 2003 environment? asp v1.x? which ajax version is compatible with asp v1.x?

Adit
+1  A: 

if you dont want to uses ajax library, try jquery

there are many plugin autocomplete or suggest textbox for jquery try this one http://www.vulgarisoip.com/2007/08/06/jquerysuggest-11/

AnhTu
A: 

The ASP.NET AJAX framework works for ASP.NET 2.0 & above. As such it will not work in Visual Studio 2003 environment.

Anthem.NET is a free, cross-browser AJAX toolkit/framework for the ASP.NET development environment that works with both ASP.NET 1.1 and 2.0 - http://sourceforge.net/projects/anthem-dot-net

For your autocomplete requirement, you can consider using the jQuery Autocomplete Plugin

It requires very less programming. Check the demo & code sample here - http://docs.jquery.com/Plugins/Autocomplete

It's autocomplete() method takes a URL or array to populate your autocompletion list. You can pass the URL of the page that fetches the results from the database directly.