AutoCompleteExtender doesn't work

R

rote

I tried using the

AutoCompleteExtender sample code below but it doesn't seem to work.
I'm not using a ServicePath="GetCompletionList.asmx"
But the textbox doesn't return anything either does it trigger
Any ideas and thanks in advance

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox runat="server" ID="myTextBox" Width="300" autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender runat="server"
ID="autoComplete1"
TargetControlID="myTextBox"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="12" />
</form>



public partial class _Default : System.Web.UI.Page {
[WebMethod]
public static string[] GetCompletionList(string prefixText, int count) {
string sql = String.Format("select companyName from customers where
companyname like @companyname + '%'");

List<string> companyList = new List<string>();
using (SqlConnection connection = new SqlConnection("Integrated
Security=SSPI;Initial Catalog=Northwind;Data Source=."))
using (SqlCommand command = new SqlCommand(sql, connection)) {
connection.Open();
command.Parameters.AddWithValue("@companyname", prefixText);
using (SqlDataReader reader = command.ExecuteReader()) {
while (reader.Read()) {
companyList.Add(reader.GetString(0));
}
}
}

return companyList.ToArray();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top