Thursday, 23 June 2011

Autocomplete using jquery ashx extension file

$("#ContentPlaceHolder2_txtLeftInsuranceName").autocomplete('../AutoComplete/AutoCompInsuranceName.ashx', { matchContains: false, minChars: 1, autoFill: false, mustMatch: true, width: 300, cacheLength: 10, max: 10 }).bind("click");



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
using PatientEstimator.BusinessLogic;
using PatientEstimator.Common;

namespace PatientEstimator.Web.AutoComplete
{
    /// <summary>
    /// Summary description for AutoCompInsuranceName
    /// </summary>
    public class AutoCompInsuranceName : IHttpHandler
    {


        public void ProcessRequest(HttpContext context)
        {
            PatientSearchBO objPatientSearchBO = new PatientSearchBO();
            PatientSearchBL objPatientSearchBL = new PatientSearchBL();

            string prefixText = context.Request.QueryString["q"];
            objPatientSearchBO.insname = prefixText;

            List<PatientSearchBO> ProviderCodeList = objPatientSearchBL.GETInsurance(objPatientSearchBO);
            StringBuilder sbProviderCodeList = new StringBuilder();

            for (int i = 0; i < ProviderCodeList.Count; i++)
            {

                sbProviderCodeList.Append(ProviderCodeList[i].insname)
                               .Append(Environment.NewLine);
            }

            context.Response.Write(sbProviderCodeList.ToString());

        }






        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

No comments:

Post a Comment