You don't need to implement a separate web-service in order to provide a textbox with auto-complete functionality, however, you do need to provide the autocomplete extender with a valid web method that it can use to call upon to retrieve the list of matching entries.
The key properties for the AutoComplete functionality of the AutoComplete Extender control are the ServiceMethod and ServicePath properties. The ServiceMethod specifies the name of the web method that is called by the AJAX framework to retrieve the matching items for your autocomplete dropdown, and the ServicePath property specifies the full path and filename for the file that will contain the ServiceMethod properties' method. Note that the ServicePath property is, however, optional.
If you omit the ServicePath property, the AJAX framework will attempt to find the ServiceMethod web method in the code within your actual web page upon which the textbox and autocomplete extender are sited. This is usually in a "code-behind" file.
From the AutoComplete Sample page:
- ServiceMethod - The web service method to be called. The signature of
this method must match the following:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)
{ ... }
Note that you can replace
"GetCompletionList" with a name of
your choice, but the return type and
parameter name and type must exactly
match, including case.
- ServicePath - The path to the web service that the extender will pull the word\sentence completions from.
If this is not provided, the service method should be a page method.