I am using the AutoCompleteExtender from the Ajax Control Toolkit and it is behaving stragely.
My service method is shown here:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getEJMaps(string prefixText, int count)
{ // method that returns the auto-suggest for the EJMaps positions
string file_location = HttpContext.Current.Server.MapPath("~") + Utils.Settings.Get("attachments") + "ejmaps\\ejmaps.xml";
XElement x = XElement.Load(file_location);
string[] positions = (from p in x.Descendants("position") where p.Value.StartsWith(prefixText) orderby p.Value select p.Value).ToArray();
if (positions.Count() == 0)
return new string[] { "No Matching Results" };
else return positions;
}
And it works fine, if I call it in a test page with the values getEJMaps("00056", 4) I get these results:
00056399
00056717
00056721
00056722
00056900
...
Which is exactly what I want, but when I tie it to a TextBox and type in 00056, I get the results:
56399
24015
24017
56717
56721
...
Which shows two problems:
I am totally baffled by this, please help me out :)
You need to surround each string in the array with quotes. For example, getEJMaps should return an array that looks like:
"00056399"
"00056717"
"00056721"
"00056722"
"00056900"
...
Don't forget you need to escape the quotes with a \
If this fixes the missing 0's but not the phantom values, let me know and I'll try to assist with that as well. I'm thinking it will though.