<%@ WebHandler Language="C#" Class="AutoCompleteByName" %>
using System;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Script.Serialization;
public class AutoCompleteByName : IHttpHandler {
    public void ProcessRequest(HttpContext context)
    {       
        string Empautoid = context.Request.QueryString["EmpAutoid"];
        string EmpCategoryShift = context.Request.QueryString["EmpCategoryShift"];
        string EmpTypeShift = context.Request.QueryString["EmpTypeShift"];
        string strDecryptedConnectionString = string.Empty;
        strDecryptedConnectionString = Cryptographys.Cryptography.GetDecryptedConnectionString();
        string searchText = context.Request.QueryString["term"];
        string connectionString = strDecryptedConnectionString;
        Collection<AutoCompleteDTO> collection;
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.Connection = connection;
                command.CommandText = "Proc_TA_AutoCompleteCommaSeparated";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@RequiredInput", searchText);
                command.Parameters.AddWithValue("@SearchType", "EmployeeName");
                command.Parameters.AddWithValue("@EmpAutoId", Empautoid);
                command.Parameters.AddWithValue("@EmpCategoryShift", EmpCategoryShift);
                command.Parameters.AddWithValue("@EmpTypeShift", EmpTypeShift);
                collection = new Collection<AutoCompleteDTO>();
                connection.Open();
                using (SqlDataReader dataReader = command.ExecuteReader())
                {
                    AutoCompleteDTO dto;
                    if (dataReader != null)
                        while (dataReader.Read())
                        {
                            dto = new AutoCompleteDTO();
                            dto.value = dto.label = (string)dataReader["Employee_FirstName"];
                            dto.id = Convert.ToString(dataReader["Employee_FirstName"]);
                            collection.Add(dto);
                        }
                }
            }
        }
        JavaScriptSerializer serializer = new JavaScriptSerializer();

        string jsonString = serializer.Serialize(collection);

        context.Response.Write(jsonString);
    }
    public bool IsReusable {
        get {
            return false;
        }
    }
}
public class AutoCompleteDTO
{
    private string myVar;

    public string id
    {
        get { return myVar; }
        set { myVar = value; }
    }
    private string myVar1;

    public string value
    {
        get { return myVar1; }
        set { myVar1 = value; }
    }
    private string myVar2;

    public string label
    {
        get { return myVar2; }
        set { myVar2 = value; }
    }
}