I\'ve tried to the letter to search for mistakes in my code, but i can\'t myself get that autocomplete extender to work. Help wanted.
Here\'s my code: (excerpt from my
As well as the GetCompletionList
method being incorrectly declared as static
, it needs to have two attributes; [System.Web.Services.WebMethod]
and [System.Web.Script.Services.ScriptMethod]
So your declaration should look like this:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count) { ...
Also your service class should have the following attributes:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
The autocomplete extender will also appear to be broken if your GetCompletionList
method throws an exception. To guard against this you should add a try..catch
block around the code the function
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)
{
List returnData = new List();
try
{
// database access code that sets returnData
}
catch (Exception ex)
{
// log the exception
}
return returnData.ToArray();
}