Posted by : Anwar Hossain
Category : How to use ajax toolkit in C#

How to use Ajax AutoCompleteExtender control in using c#

Dear viewers I will show how to use an AutoCompleteExtender control to a TextBox in order to display auto-complete suggestions item. The AutoCompleteExtender works with a standard ASP.NET TextBox control .At first I have taken a TextBox and an AutoCompleteExtender. Then Codebehind page I have created Employee list to supply data to TextBox and an AutoCompleteExtender but real-time list will be created by collecting data from database. I have shown this example without using Webservice.

Ajax AutoCompleteExtender control


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
  <title>AutoComplete Extender</title>
  <form runat="server">
  <b style = "color:Red;">Enter Customer Name</b>
  <asp:TextBox ID="txtContactsSearch" runat="server"></asp:TextBox>
  <asp:AutoCompleteExtender ID="txtContactsSearch_AutoCompleteExtender" MinimumPrefixLength="1"
  ServiceMethod="SearchCustomers" CompletionInterval="100" EnableCaching="false"
  CompletionSetCount="10" TargetControlID="txtContactsSearch" runat="server" FirstRowSelected="false">
  <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class AutoCompleteExtender : System.Web.UI.Page
  protected void Page_Load(object sender, EventArgs e)
  private static List<Customer > GetStudent()
  List<Customer > Customers = new List<Customer >()
    new Customer  {Name = "Roman"},
    new Customer  {Name = "Iqbal"},
    new Customer  { Name = "Amin"},
    new Customer  {  Name = "Asad"},
    new Customer  {  Name = "Abul"},
    new Customer  {  Name = "Abaden"},
    new Customer  { Name = "M Ali"},
    new Customer  {  Name = "Ashikur Rhaman"},
    new Customer  {  Name = "Abdul"},
    new Customer  {  Name = "Asif"},
    new Customer  {  Name = "Aminur"},
    new Customer  {  Name = "Arifur Rahman"},
    new Customer  {  Name = "Asgor"},
    new Customer  {  Name = "Abul Momen"
  return Customers;
  public class Customer
    public string Name { get; set; }
  [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
  public static List<string> SearchCustomers(string prefixText, int count)
  List<Customer > CustomeList = GetStudent();
  var query = from m in CustomeList
  select m.Name.ToString();
  return (from customer in query
  where customer.ToLower().StartsWith(prefixText.ToLower())
  select customer).Take (count).ToList<string>();
  catch (Exception ex )
  throw new Exception("Problem Loading in finding customer" + ex.Message);

Out Put


Realted Article Headline

How to use TextBoxWatermarkExtender in using c#
How to use Ajax AutoCompleteExtender control in using c#
How to use Ajax Collapsible panel control in c#
How to use ASP.Net AJAX Control Toolkit ModalPopupExtender Control in c#
how to add an Ajax Control Toolkit Accordion to a page
How to use html editor Ajax control toolkit example in c#
How to use Ajax ConfirmButtonExtender in using c#
how to use ajax calendar extender in asp net c#
How to use ajax toolkit FilteredTextBox Control in c#

Article Category

How to create control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C# c # basic tutorial
How to use ajax toolkit in C#
How to use different types of validation control using c#
How to use grid view in c#
Protected by Copyscape Online Plagiarism Detection