Click here to Skip to main content
15,399,440 members
Articles / Web Development / ASP.NET
Posted 28 Jun 2012


16 bookmarked

ASP.NET Ajax AutoCompleteExtender Without Using Web Service

Rate me:
Please Sign up or sign in to vote.
4.76/5 (12 votes)
28 Jun 2012CPOL
ASP.Net Ajax AutoCompleteExtender without using Web Service


This tip shows how to use Ajax AutoCompleteExtender in an ASP.NET application, without adding a Web Service.


  • Create an ASP.NET 4.0 Web Application
  • Add reference to AjaxControlToolit
  • Open Default.aspx
  • Add Script Manager
  • Add Ajax AutoCompleteExtender 

Using the Code

Using the code (default.aspx)

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" 
EnablePageMethods = "true">

Enter a Product Name
<asp:TextBox ID="txtProductList" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="GetProductList" 
    CompletionInterval="0" EnableCaching="false" CompletionSetCount="10" 
    ID="autoCompleteExtender1" runat="server" FirstRowSelected = "false">


    public static string[] GetProductList(string prefixText, int count)
        // Get the Products From Data Source. Change this method to use Database
        List<string> productList = GetProducts();

        // Find All Matching Products
        var list = from p in productList
                   where p.Contains(prefixText)
                   select p;

        //Convert to Array as We need to return Array
        string[] prefixTextArray = list.ToArray<string>();

        //Return Selected Products
        return prefixTextArray;

Points of Interest

  • If you want that your method responds to the Scripting Language, make sure to add [System.Web.Script.Services.ScriptMethod()] to method attribute. Else, this won't work
  • And yes, this does not require addition of Web Service!


  • 29th June, 2012: Initial version
This article was originally posted at


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ameet Parse
India India
I am a Tech Lead / .Net Architect,

I love working with Business Challenges, Requirements

I work mainly for Designing eCommerce Portals Using ASP.Net enabled Frameworks such as Mediachase, zNode and Storefront.

I love writing my Articles at Code Project and my site

Comments and Discussions

QuestionThis worked great. Pin
Greg Pierce7-Aug-14 11:51
MemberGreg Pierce7-Aug-14 11:51 
GeneralThank you Pin
Tuduru Sai Krishna21-Jan-14 19:08
MemberTuduru Sai Krishna21-Jan-14 19:08 
Questionautoextender is not working Pin
abhinav_8917-Jul-13 21:28
Memberabhinav_8917-Jul-13 21:28 
GeneralMy vote of 5 Pin
Reza Ahmadi28-Jun-13 0:39
MemberReza Ahmadi28-Jun-13 0:39 
GeneralMy vote of 4 Pin
Musthaan19-Mar-13 3:13
MemberMusthaan19-Mar-13 3:13 
QuestionGood Article Pin
Alireza_136222-Dec-12 0:46
MemberAlireza_136222-Dec-12 0:46 
GeneralReally not a web service? Pin
Pankaj Nikam5-Jul-12 22:04
professionalPankaj Nikam5-Jul-12 22:04 
GeneralRe: Really not a web service? Pin
Ameet Parse6-Jul-12 23:49
MemberAmeet Parse6-Jul-12 23:49 
GeneralMy vote of 5 Pin
Kamil Zmeskal29-Jun-12 4:14
MemberKamil Zmeskal29-Jun-12 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.