AjaxControlToolkit AutoCompleteExtender列表未在Google Chrome中显示

时间:2015-09-23 10:41:11

标签: c# html ajaxcontroltoolkit

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

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

自动填充网络服务

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

2 个答案:

答案 0 :(得分:0)

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

将以下内容添加到自动填充网络服务,并将您的网络服务方法设为static

[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod]

public static string[] AutoCompleteAjaxRequest(string prefixText, int count)

答案 1 :(得分:0)

我删除了AjaxControlToolKit dll文件并使用Nuget再次安装它并且它工作了...我猜下载/引用前一个dll文件时出错了。