Hey All, I’ve been fighting with this all day. I’ve read a multitude of tutorials and I can not get the AutoCompletedExtender working.
Here is my aspx page code:
<asp:TextBox ID="brandTXT" runat="server" AutoPostBack="true"></asp:TextBox>
<asp:AutoCompleteExtender ID="brandTXT_AutoCompleteExtender" runat="server"
MinimumPrefixLength="1" CompletionInterval="100" Enabled="True"
ServicePath="~/WebService.asmx" EnableCaching="true"
CompletionSetCount="20" ServiceMethod="GetCompletionList" TargetControlID="brandTXT">
</asp:AutoCompleteExtender>
Here is my WebService.asmx:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class WebService
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetCompletionList(prefixText As String, ByVal count As Integer) As List(Of String)
Dim ConnStr As String = ConfigurationManager.ConnectionStrings("connectionString").ConnectionString
Dim CnBKPost As New SqlConnection(ConnStr)
Dim result As List(Of String) = New List(Of String)
Dim cmd As New SqlCommand
cmd.CommandText = "selectBrandByLetter" <- sql command
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = CnBKPost
cmd.Parameters.AddWithValue("@brand", prefixText)
CnBKPost.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read()
result.Add(dr("Manufacturer").ToString())
End While
CnBKPost.Close()
Return result
End Function
End Class
The stored procedure is a simple select statement
SELECT dbo.Inventory.Manufacturer
FROM dbo.Inventory
WHERE dbo.Inventory.Manufacturer LIKE @brand + '%'
GROUP BY dbo.Inventory.Manufacturer
ORDER BY dbo.Inventory.Manufacturer
I can run the stored procedure perfectly with proper results, and I can run a test page with returning the results in a button click command. So I know everything on the database end of things is working fine.
I’ve added my service reference for the WebService.asmx page as well to my solution.
There are no errors, just nothing happens on the page at all…
I am stumped, any help would be great!