zoukankan      html  css  js  c++  java
  • 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,否则不会进行提示;

  • 相关阅读:
    Apache Jmeter 性能测试
    linux 达梦数据库 命令行 卸载
    vue控制台报错Duplicate keys detected: 'xxxx'. This may cause an update error.解决方案
    springboot报错说 Failed to parse multipart servlet request; nested exception is java.io.IOException
    简单理解Callable接口
    Windows下设置Mongodb用户名密码
    Win10 搭建FTP环境,并使用Java实现上传,下载,删除
    【小组展示】1
    【计网II】
    【密码学】AES
  • 原文地址:https://www.cnblogs.com/songling/p/2217813.html
Copyright © 2011-2022 走看看