[英]Asp.Net autoComplete Extender after populating values pressing down arrow not navigating through populated values
我正在使用AjaxAutoComplete Extender來填充旅途中的城市值。但是我有一個問題。
一切正常,但是當我按向下箭頭瀏覽結果時,它什么也沒做,它永遠不會偏離第一個結果。
值也填充在網頁的頂部,而不是文本框的下方。之前它可以正常工作,但現在不行。
ASP.NET
<asp:TextBox ID="fromlocation" runat="server" CssClass="ddl"></asp:TextBox>
<autofill:AutoCompleteExtender
ServiceMethod="GetCompletionList"
ID="fromlocation_AutoCompleteExtender"
runat="server"
DelimiterCharacters=""
Enabled="True"
ServicePath=""
TargetControlID="fromlocation"
UseContextKey="True"
MinimumPrefixLength="2"
CompletionInterval="10"
EnableCaching="true"
CompletionSetCount="3"
CompletionListItemCssClass="autocomplete_listItem">
</autofill:AutoCompleteExtender>
C#
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connstring"].ToString());
SqlCommand cmd = new SqlCommand("SELECT coalesce(Code + ', ', '') + City as codes FROM CCode WHERE City LIKE '" + prefixText + "%'", conn);
SqlDataReader oReader;
conn.Open();
List<string> CompletionSet = new List<string>();
oReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (oReader.Read())
CompletionSet.Add(oReader["codes"].ToString());
return CompletionSet.ToArray();
}
上面的解決方案在另一個論壇中列出。.我通過谷歌搜索發現了..
在上面的代碼中我只添加了
CompletionListItemCssClass="autocomplete_listItem"
但是在那個論壇上,thay提到了還要定義以下代碼。
CompletionListHighlightedItemCssClass="two"
我做到了,現在我的問題解決了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.