-4
    [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();
        }
    }

<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>

これらのほとんどは、Toolkit サンプル Web サイトから直接引用しています。また、データベースから配列を埋めることを除いて、サンプルとまったく同じように Web サービスを使用してそれを行いました。どちらも問題なく配列を満たし、両方とも時々動作します。賢明なパフォーマンスの欠如、それらは同一のように見えます。

私は別のページでいくつかのカレンダー コントロールを使用していますが、それらは問題なく動作しますが、これを一貫して機能させるために多くの時間を浪費してしまいました。

4

1 に答える 1