AJAX Control Toolkit - ListSearch
1.ListSearch Server Reference
PromptText - Message to display when the ListBox or DropDownList is given focus. Default is 'Type to search'. The PromptText is replaced by the search text typed by the user.
PromptCssClass - The name of the CSS class to apply to the prompt message.
PromptPosition - Indicates whether the message should appear at the Top or Bottom of the ListBox. The default is Top.
QueryPattern - Indicates how the typed characters should be used in the search query. The default pattern queries for results that start with the typed word.
IsSorted - Indicates if items added to the List are expected to be sorted. The default is false. If set to true it allows the code to perform a faster search instead of having to determine the same before performing the search.
QueryTimeout - Indicates whether the search query should be reset after the timeout if no match is found. The default is 0, meaning no auto reset behavior.
Animations- Generic animations for the ListSearch extender. See the Using Animations walkthrough and Animation Reference for more details.
- OnShow- The OnShow animation will be played each time the extender's prompt is displayed. The prompt will be positioned correctly but hidden. The animation can use
to display the prompt along with any other visual effects. - OnHide - The OnHide animation will be played each time the
1 <asp:ScriptManager ID="ScriptManager1" runat="server" />
2 <br />
3 <div style="text-align: center">
4 Click on this ListBox and start typing to search for an entry:
5 <br />
6 <br />
7 List Box:<br />
8 <br />
9 <asp:ListBox ID="ListBox1" runat="server" Width="100px" />
10 <ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ListBox1"
11 PromptCssClass="ListSearchExtenderPrompt">
12 </ajaxToolkit:ListSearchExtender>
13 <br />
14 <br />
15 DropDownList:<br />
16 <br />
17 <asp:DropDownList ID="DropDownList1" runat="server" Width="100px" />
18 <ajaxToolkit:ListSearchExtender ID="ListSearchExtender2" runat="server" TargetControlID="DropDownList1"
19 PromptCssClass="ListSearchExtenderPrompt">
20 </ajaxToolkit:ListSearchExtender>
21 </div>

1 protected override void OnLoad(EventArgs e)
2 {
3 base.OnLoad(e);
4 ListBox1.DataSource = GetWordListText();
5 ListBox1.DataBind();
6 DropDownList1.DataSource = GetWordListText();
7 DropDownList1.DataBind();
8 }
9
10
11 private static string[] wordListText;
12 public string[] GetWordListText()
13 {
14 // This is the NATO phonetic alphabet (http://en.wikipedia.org/wiki/NATO_phonetic_alphabet)
15 // and was chosen for its size, non-specificity, and presence of multiple words with the same
16 // starting letter.
17 if (null == wordListText)
18 {
19 string[] tempWordListText = new string[] {
20 "Alfa",
21 "Alpha",
22 "Bravo",
23 "Charlie",
24 "Delta",
25 "Echo",
26 "Foxtrot",
27 "Golf",
28 "Hotel",
29 "India",
30 "Juliett",
31 "Juliet",
32 "Kilo",
33 "Lima",
34 "Mike",
35 "November",
36 "Oscar",
37 "Papa",
38 "Quebec",
39 "Romeo",
40 "Sierra",
41 "Tango",
42 "Uniform",
43 "Victor",
44 "Whiskey",
45 "X-ray",
46 "Xray",
47 "Yankee",
48 "Zulu",
49 "Zero",
50 "Nadazero",
51 "One",
52 "Unaone",
53 "Two",
54 "Bissotwo",
55 "Three",
56 "Terrathree",
57 "Four",
58 "Kartefour",
59 "Five",
60 "Pantafive",
61 "Six",
62 "Soxisix",
63 "Seven",
64 "Setteseven",
65 "Eight",
66 "Oktoeight",
67 "Nine",
68 "Novenine"
69 };
70 Array.Sort(tempWordListText);
71 wordListText = tempWordListText;
72 }
73 return wordListText;
74 }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步