Autocomplete Textbox im asp.net

a generic handler file is used:
<%@ WebHandler Language="C#" Class="AutocompleteData" %>

using System;
using System.Web;
using System.Data.SqlClient;

public class AutocompleteData : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");
        string firstname = context.Request.QueryString["q"];
        string sql = "select Mobile_No from Information where Mobile_No like '" + firstname + "%'";
        using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString))
        using (SqlCommand command = new SqlCommand(sql, connection))
        {
            connection.Open();
            using (SqlDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    context.Response.Write(reader.GetString(0) + Environment.NewLine);
                }
            }
        }

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

}

two jquery are used

jquery-1.3.2_1
jquery.autocomplete

in page.aspx file write the code:..
<head runat="server">
    <title>Untitled Page</title>
    <script language ="javascript" type ="text/javascript" src ="script/jquery-1.3.2_1.js" ></script>
    <link rel="stylesheet" href ="script/jquery.autocomplete.css"  type="text/css" />
    <script language ="javascript" type ="text/javascript" src ="script/jquery.autocomplete.js" ></script>
    <script type="text/javascript">
     $(document).ready(function(){  $("#fname").autocomplete("AutocompleteData.ashx");
       });
      </script>
   
</head>
<body>

    <form id="form1" runat="server">
    <div>
    Search: <input id="fname" type="text" />
       </div>
    </form>
</body>




X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now