我有一個ASP.NEt應用程序與一個Ajax自動完成擴展和它工作正常,但我只希望在列表中看到10到15個元素。我該怎麼做?如何設置十個元素的AutoCompleteList?
ASPX:
<asp:TextBox ID="txtVertreter" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoComlete" runat="server" TargetControlID="txtVertreter"
ServiceMethod="GetCompletionList" ServicePath="" Enabled="true"
DelimiterCharacters="" UseContextKey="true" MinimumPrefixLength="1" ></asp:AutoCompleteExtender>
我的CS代碼:
[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
ArrayList filteredList = new ArrayList();
string s2 = "\n";
char[] ch = s2.ToCharArray();
UserService srv = new UserService();
ArrayList AList = srv.VertreterFinden(Domain, prefixText);
string[] names = AList.ToArray(typeof(string)) as string[];
foreach (string name in names)
{
if
(name.ToLower().StartsWith(prefixText.ToLower()))
{
filteredList.Add(name);
}
} return (string[])
filteredList.ToArray(typeof(string));
}
你想要精確10還是10-15之間? – freebird
10 ................... – Tarasov