Wednesday, July 13, 2011

Autocomplete textbox in ASP.NET using Ajaxcontroltoolkit

AutoComplete is an ASP.NET AJAX extender that can be attached to any TextBox control, and will associate that control with a popup panel to display words that begin with the prefix typed into the textbox.


To make a textbox autocomplete suggestion we can use jquery or ASP.NET ajaxcontroltoolkit. Today I will try to describe how to make autocomplete textbox using ajaxcontroltoolkit. I think its not a complicated work but I saw a lot of question in different forum. Let starts......

We need a  textbox and autocomplete item from visual studio 2008 toolbox.
We need web service. For adding web service a need a web service class. We can add web service by following.

Then we add a method GetCompany that returns string array. We will fetch data from database using prefix string than convert the list of data by string array format. Please check following.
Then we call the method from the ajax autocomplete tool. Like this..

Here is autocomplete tool necessary properties. Service method is the method we need to call from web service class. Service path is the web service path where the asmx page reside.
 You should add a script manager in your page top. 
Hope its done. How simple it is?
Example.








1 comment:

Search This Blog

Visitor Counter