1

i have a web form on asp.net and a textbox and a button to search data from website i want to implement a auto complete property on my textbox it runs perfectly but shows nothing i have given 2 length for prefix and i have added ajax tool kit as well in my project please help me through it, on my WEB FORM 1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ESEPAK.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <title></title>
    <link href="css/bootstrap.css" rel="stylesheet" />
    <link href="css/bootstrap.min.css" rel="stylesheet" />
   <%-- <link href="css/bootstrapAmelia.css" rel="stylesheet" />
    <link href="css/bootstrapAmelia.min.css" rel="stylesheet" />--%>
</head>
<body>
    <form id="form1" runat="server">


          <div>            

              <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

           <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
                    ServiceMethod="AutoCompleteAjaxRequest"
                    ServicePath="AutoComplete.asmx"
                    MinimumPrefixLength="2"
                    CompletionInterval="100"
                    EnableCaching="false"
                    CompletionSetCount="10"
                    TargetControlID="TextBox1" 
                    FirstRowSelected="false">
        </asp:AutoCompleteExtender>

             </div>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server"></asp:UpdatePanel>

on my Web Form1.aspx.cs

namespace ESEPAK
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]

        public partial class WebForm1 : System.Web.UI.Page
        {

            Database _db = DatabaseFactory.CreateDatabase();

            DataSet ds = new DataSet();
            SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
            protected void Page_Load(object sender, EventArgs e)
            {
            }
             public class AutoComplete : System.Web.Services.WebService
            {

                [WebMethod]
                public string[] AutoCompleteAjaxRequest(string prefixText, int count)
                {
                    List<string> ajaxDataCollection = new List<string>();
                    DataTable dt = new DataTable();
                    dt = getdata(prefixText);
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ajaxDataCollection.Add(dt.Rows[i]["Name"].ToString());
                        }
                    }
                    return ajaxDataCollection.ToArray();
                }
            public DataTable getdata(string prefixText)
            {
                SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
                string query = "select * from SHOPHIVECAT";

                SqlDataAdapter sda = new SqlDataAdapter(query, Conn);
                DataTable dt = new DataTable();

                sda.Fill(dt);
                return dt;
            }
        }}}
  • [Kindly check Follow the Steps in the link](http://stackoverflow.com/questions/312318/how-can-i-get-my-autocomplete-extender-to-work) – Manish Goswami Jul 14 '16 at 13:47
  • @ManishGoswami but in that i will call a non static with a static method? and i hope there is nothing wrong with my registry line above aspx webform or i don't know why it's not working, – Shehroz Jalil Jul 14 '16 at 13:59
  • @ManishGoswami tried that, even that is not working :( – Shehroz Jalil Jul 14 '16 at 14:24
  • @ManishGoswami is this error because of pageload? i have done nothing on my page load event – Shehroz Jalil Jul 14 '16 at 14:35
  • i got this you are doing it so wrong you have copied code and u just placed it on page load. try this on your ASP web form click on Add new item in your project and add web service , will be named like WebService1.asmx and then place all the .cs class code there hope it will work, – Muhammad Mateen Jul 16 '16 at 05:31

0 Answers0