• autoComplete 传递第三个参数


    前台代码:

    <script type="text/ecmascript">
            function OnTxtKeyDown() {
                var acNameClientId = "<%=autoComplete1.BehaviorID %>";
                var acName = $find(acNameClientId);
                if (acName != null) {
                    acName.set_contextKey('需要传递的参数');
                }
            }
        </script>

    <asp:TextBox ID="txt" runat="server" Width="150" onkeydown="return OnTxtKeyDown();"></asp:TextBox>


    <ajaxToolkit:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx" ID="autoComplete1"
                            TargetControlID="txt" ServicePath="AutoComplete.asmx" ServiceMethod="Search"
                            MinimumPrefixLength="0" CompletionInterval="1000" EnableCaching="false" CompletionSetCount="10"
                            CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
                            CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"
                            ShowOnlyCurrentWordInCompletionListItem="true">

    webservice方法:

     [WebMethod]
        public string[] GetCompletionList(string prefixText, int count,string contextKey)
        {
            if (count == 0)
            {
                count = 10;
            }

            if (prefixText.Equals("xyz"))
            {
                return new string[0];
            }

            Random random = new Random();
            List<string> items = new List<string>(count);
            for (int i = 0; i < count; i++)
            {
                char c1 = (char) random.Next(65, 90);
                char c2 = (char) random.Next(97, 122);
                char c3 = (char) random.Next(97, 122);

                items.Add(prefixText + c1 + c2 + c3);
            }

            return items.ToArray();
        }

    需要注意的是第三个参数名字必须为string contextKey,否则不会进行提示;

  • 相关阅读:
    poj 1237 The Postal Worker Rings Once // hoj 1164 The Postal Worker Rings Once
    poj3096Surprising Strings
    Telnet服务的配置2(转)
    浅谈以太网帧格式(转)
    QT for linux 的错误 undefined reference to 'FcFreeTypeQueryFace' 的解决方法(转)
    CString,int,string,char*之间的转换(转)
    sprintf(转)
    CString类(转)
    Linux下telnet服务的配置(转)
    grub删除后的windows恢复(转)
  • 原文地址:https://www.cnblogs.com/songling/p/2217813.html
Copyright © 2020-2023  润新知