Reputation: 381
part of My aspx page
<asp:TextBox runat="server" id= "TextBox1" ></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
runat="server" TargetControlID="TextBox1"
MinimumPrefixLength="0" ServiceMethod="getAutoComplete()"
ServicePath="nationality.aspx.cs"
>
</ajaxToolkit:AutoCompleteExtender>
my aspx.cs code:
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] getAutoComlete(string prefixText, int count, string contextKey)
{
string[] a = { "11", "22", "33" };
return a;
}
I am trying to make autocomplete . What am I doing wrong?
Upvotes: 1
Views: 543
Reputation: 2145
If you have your service code on same page of your control, then it will directly call your service code.
try below,
//change asp page like this
<asp:TextBox runat="server" id= "TextBox1" ></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
runat="server" TargetControlID="TextBox1"
MinimumPrefixLength="0" ServiceMethod="getAutoComplete">
</ajaxToolkit:AutoCompleteExtender>
// change your .cs code as below
[System.Web.Services.WebMethod(true)]
public static string[] GetCompletionList(string prefixText, int count)
{
string[] a = { "11", "22", "33" };
return a;
}
Hope it helps.
Upvotes: 0
Reputation: 1433
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] getAutoComplete(string prefixText, int count, string contextKey)
{
string[] a = { "11", "22", "33" };
return a;
}
You are not using the samename function on the aspx page and the C# code :)
Upvotes: 2