By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,684 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,684 IT Pros & Developers. It's quick & easy.

AutoCompleteExtender doesn't work

P: n/a
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<stringcompanyList = 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();
}
Jun 1 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.