First of all add AjaxControlToolKit reference


CSS
 
 
  Normal
  0
  
  
  
  
  false
  false
  false
  
  EN-US
  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
   
  
  
   
   
   
   
   
   
   
   
   
   
   
  

 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 


 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin-top:0in;
	mso-para-margin-right:0in;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;}

<%@ Register Assembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"
TagPrefix="cc1"%>

JavaScript for load image

HTML / XML
 <script type="text/javascript">
    function ShowIcon() {
    
    var e = document.getElementById("loading");
    e.style.visibility =  (e.style.visibility == 'visible') ? 'hidden' : 'visible';
    }          
    </script>

Design Code

HTML / XML
 <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
    </asp:ScriptManager>
    <asp:TextBox ID="txtemployee" runat="server" Width="40%" Height="15px" OnTextChanged="txtemployee_TextChanged"></asp:TextBox>
    <img id="loading" style="visibility: hidden" src="IMAGES/ajax-loader.gif" />
    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" EnableCaching="true"
        TargetControlID="txtemployee" ServiceMethod="GetCities" ServicePath="WebService.asmx"
        OnClientPopulating="ShowIcon" OnClientPopulated="ShowIcon" MinimumPrefixLength="1"
        CompletionSetCount="10" FirstRowSelected="true">

Web service Function Code

C#
 using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data;
using System.Collections.Generic;
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
    public string[] GetCities(string prefixText)
    {
        SqlConnection con = new SqlConnection("Data Source=BITPLUS5\\SqlExpress;Initial Catalog=WEBHR_22112011;User ID=sa;pwd=bit123;");
        
        con.Open();
        string strQuery = "select emp_name from tblemployee where emp_name like '" + prefixText + "%'";

        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(strQuery, con);
        da.Fill(ds);
        con.Close();
        List<string> cityList = new List<string>();
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            cityList.Add(ds.Tables[0].Rows[i][0].ToString());
        }
        con.Close();
        return cityList.ToArray();
    }
}