• 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,否则不会进行提示;

  • 相关阅读:
    【Python】supervisor安装和管理celery
    【MySQL】pt-query-digest数据处理并关联业务
    【Python】pip国内安装源和yum恢复
    【Python】Celery异步处理
    【转】Java中堆和栈的区别
    三种简单排序算法
    哈夫曼(Huffman)编码
    SpringMVC之文件上传
    SpringMVC之类型转换
    SpringMVC之表单校验
  • 原文地址:https://www.cnblogs.com/songling/p/2217813.html
Copyright © 2020-2023  润新知