[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetRowsByFilter(string prefixText, int count)
//public static List<string> GetRowsByFilter(string prefixText)
{
DataTable table = ds.Tables[0];
string filter = "stShortName LIKE '" + prefixText.Replace("'", "''") + "%'";
DataRow[] foundRows;
List<string> items = new List<string>(count);
foundRows = table.Select(filter);
if (foundRows.Length > 0)
{
for (int i = 0; i < foundRows.Length; i++)
{
items.Add((string)foundRows[i]["stShortName"]);
}
return items.ToArray();
}
else
{
items.Add("No '" + prefixText + "' items found");
return items.ToArray();
}
}
and
<ajaxToolkit:AutoCompleteExtender
id="AutoCompleteExtenderTxtSite"
BehaviorID="AutoCompleteEx"
Runat="server"
Targetcontrolid="txtSiteASP"
ServiceMethod="GetRowsByFilter"
MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="false"
CompletionSetCount="10"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true"
>
<Animations>
<OnShow>
<Sequence>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<Parallel Duration=".4">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</ajaxToolkit:AutoCompleteExtender>
Most of this is directly out of the Toolkit sample website. I have also done it using the web service exactly as from sample except with filling the array from the database. Both fill the array flawlessly, and both work sometimes. Lack of performance wise, they appear to be identical.
I use a couple of the calendar controls on another page and they work flawlessly, but have wasted way too much time trying to make this work consistently.