AjaxControlToolkit AutoCompleteExtender列表不显示在谷歌Chrome浏览器

本文关键字:谷歌 Chrome 浏览器 显示 AutoCompleteExtender 列表 AjaxControlToolkit | 更新日期: 2023-09-27 18:14:01

使用下面的代码,我成功地能够在Firefox和IE中显示文本框上的自动完成列表,但它没有显示在google chrome中,请帮助我。成功地从数据库中检索数据。我调试了一下,没有错误。

   <style  type="text/css">

.AutoExtender 
{ 
    font-size: 12px; 
    color: #000; 
    padding: 3px 5px; 
    border: 1px solid #999; 
    background: #fff; 
    width: auto; 
    float: left; 
    z-index: 9999999999; 
    position:absolute; 
    margin-left:0px; 
    list-style: none; 
    font-weight: bold; 
} 
        .listItem {
        color: #191919;
        } 
        .itemHighlighted {
        background-color: #ADD6FF;       
        }
</style>

<asp:TextBox ID="TextBox1" placeholder="SELECT * FROM TABLEA" class="enjoy-css" runat="server"  autocomplete="off"  TextMode="multiline"> 
             </asp:TextBox>
      <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

    <AjaxControlToolkit:AutoCompleteExtender 
    runat="server" 
    ID="AutoCompleteExtender1" 
    BehaviorID="AutoCompleteExtender1"
    TargetControlID="TextBox1"
    ServiceMethod="AutoCompleteAjaxRequest"
    ServicePath="AutoComplete.asmx"
    MinimumPrefixLength="3" 
    CompletionInterval="100"
    EnableCaching="true"
    CompletionSetCount="100" 
    CompletionListCssClass="AutoExtender"
    CompletionListItemCssClass="listItem"
    FirstRowSelected="true"
    CompletionListHighlightedItemCssClass="itemHighlighted"
    DelimiterCharacters=";, :'n'r"
    showonlycurrentwordincompletionlistitem="true"
    >
</AjaxControlToolkit:AutoCompleteExtender>

自动完成web服务

    public string[] AutoCompleteAjaxRequest(string prefixText, int count)
    {
        Match match;
        match = Regex.Match(prefixText, "(''w+)$");

        List<string> ajaxDataCollection = new List<string>();
        if (match.Success)
        {
            String Query = "SELECT TABLE_NAME FROM(select TABLE_NAME from INFORMATION_SCHEMA.COLUMNS  UNION select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS ) COLUMN_NAME WHERE TABLE_NAME like '%" +match.Value+"%';";
            DataTable dt = this.GetData(Query, CreateConnectionString(UserName, Password, DatabaseName, DataSource));
            if (dt.Rows.Count > 0)
            {
                int countt = dt.Rows.Count;
                for (int i = 0; i < countt; i++)
                {
                    ajaxDataCollection.Add(dt.Rows[i]["TABLE_NAME"].ToString());
                }
            }
                ajaxDataCollection.Add("SELECT");
                ajaxDataCollection.Add("WHERE");
                ajaxDataCollection.Add("UPDATE");
                ajaxDataCollection.Add("INSERT");
                ajaxDataCollection.Add("DELETE");
                ajaxDataCollection.Add("EXEC");
                ajaxDataCollection.Add("FROM");
                ajaxDataCollection.Add("VALUES");
                ajaxDataCollection.Add("HAVING");
            return  ajaxDataCollection.ToArray();
        }

AjaxControlToolkit AutoCompleteExtender列表不显示在谷歌Chrome浏览器

这是我在你的代码中观察到的几点:

自动完成web服务中添加以下内容,并将web服务方法设置为static

[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod]
public static string[] AutoCompleteAjaxRequest(string prefixText, int count)

我删除了AjaxControlToolKit dll文件,并使用Nuget再次安装它,它工作了…我猜下载/引用以前的DLL文件时出了问题。