0

I would like to seek help in my project. I am having a hard time with AutoCompleteExtender. I have search a lot and followed the codes but it seems to be not working.

Here is my output enter image description here

This is my code:

<asp:TextBox ID="txtSearch" runat="server" CssClass="form-control" Width="178px" MaxLength="30"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtSearch" ServiceMethod="GetAccountNo" MinimumPrefixLength="1" CompletionSetCount="1" CompletionInterval="10"></ajaxToolkit:AutoCompleteExtender>

  <System.Web.Script.Services.ScriptMethod()>
    <System.Web.Services.WebMethod>
    Public Function GetAccountNo(ByVal prefix As String) As String()
        OpenConn()
        strsql = "SELECT account_no FROM meter_info WHERE account_no LIKE '%'+@SearchText+'%'"
        cmd = New SqlCommand(strsql, conn)
        cmd.Parameters.AddWithValue("@SearchText", prefix)
        da = New SqlDataAdapter(cmd)
        dt = New DataTable
        da.Fill(dt)

        Dim accno As List(Of String) = New List(Of String)
        For i As Integer = 0 To i < dt.Rows.Count - 1
            accno.Add(dt.Rows(i)(0).ToString)
        Next
    End Function
Miguel Intoy
  • 73
  • 11

1 Answers1

0

Ajax list doesnt work properly, i will suggest better idea with Jquery.

                $( function() {
              var availableTags = [
                  <%
          Dim ddt As New DataTable : ddt = Session("CurList")
          For Each dr As DataRow In ddt.Rows                 
              Response.Write("'" & dr("Qparam") & "',")
          Next
          %>
              ];
              $( "#<%:txtDef.ClientID%>" ).autocomplete({
                   source: availableTags 
              });
          } );
Ravindra
  • 66
  • 6