The listsearchextender control is used to quickly search and locate the content in the list. Applicable to the ListBox and dropdownlist controls.
See the example below:
1) Create an ASP. NET Ajax-enabled web project in vs2005 and name it listsearchextender1.
2) drag and drop a ListBox control and sqldatasource on the default. aspx page. Configure sqldatasource and use the productname field in products of northiwind. Set the datasourceid of ListBox to sqldatasouce1.
CodeAs follows: 1 < BR />
2 < ASP: ListBox ID = "Listbox1" Runat = "Server" Performanceid = "Sqlperformance1" Datatextfield = "Productname" Width = "250px" > </ ASP: ListBox > < BR />
3 < BR />
4 < ASP: sqldatasource ID = "Sqlperformance1" Runat = "Server" Connectionstring = "<% $ Connectionstrings: northwindconnectionstring %>"
5 Selectcommand = "Select [productname], [productid] from [alphabetical list of products] order by productname ASC" > </ ASP: sqldatasource >
6 < BR />
3) drag and drop a listsearchextender control on the page and set its attributes.
The Code is as follows: 1 < C0: listsearchextender ID = "Listsearchextender1" Targetcontrolid = "Listbox1" Promptcssclass = "Listsearchextenderprompt" Prompttext = "Input letters" Runat = "Server" >
2 </ C0: listsearchextender >
4) press Ctrl + F5 to view the effect in the browser.
As follows:
Note:
1) This control can be used with the ListBox and dropdownlist controls.
2) You cannot enter Chinese characters in the prompttext of the control (I cannot solve it at present). If you enter Chinese, a strange phenomenon will occur.
For example: