You must Sign In to post a response.
  • Category: JavaScript

    InputBox autocomplete in asp classic

    i would like to autocomplete display help from database when type into inputbox.
  • #751319
    Hi,

    What you want exactly, I didn't get your point. I think you are looking for autocomplete information based on user entry right.?

    If you are looking for the same then refer below sample code for your reference and implement your task based on this.


    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <ajaxToolkit:AutoCompleteExtender ID="autoExtender" runat="server" TargetControlID="txt1" ServiceMethod="GetEmpNames"
    MinimumPrefixLength="1" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"></ajaxToolkit:AutoCompleteExtender>


    and in code behind wrote below lines of code


    [System.Web.Script.Services.ScriptMethod()]

    [System.Web.Services.WebMethod]

    public static List GetEmpNames(string prefixText)
    {
    SqlConnection con = new SqlConnection("DataBase=ENGSOFT;User id=sa;Password=P@ssword9");
    con.Open();
    SqlCommand cmd = new SqlCommand("select empno, ename,job,mgr,hiredate,sal,comm,picture from emp where ename like '%'+ @Name+'%'", con);
    cmd.Parameters.AddWithValue("@Name", prefixText);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable();
    da.Fill(dt);

    List Empname = new List();

    for (int i = 0; i < dt.Rows.Count; i++)
    {
    Empname.Add(dt.Rows[i]["ename"].ToString());
    }
    con.Close();
    return Empname;
    }


    Try same like above.

    Hope this will helpful to you..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #751324
    Hi DHARMENDRA KUMAR , There are huge number of related articles available in internet if you searched. Please go through those things here with i am providing a reference link you can get benefit fo this.

    http://www.experts-exchange.com/Programming/Languages/Scripting/ASP/Q_28324432.html

    http://api.jqueryui.com/autocomplete/#option-minLength

    Naveen his requirement is in Classic Asp how to do auto completion for a input control.

    Rajesh B
    To Live More,Learn More


  • Sign In to post your comments