articles

Home / DeveloperSection / Articles / Ajax Toolkit ListSearchExtender Control in ASP.Net

Ajax Toolkit ListSearchExtender Control in ASP.Net

Pushpendra Singh16379 07-Dec-2010

The ListSearchExtender lets you search for items in a ListBox or DropDownList. The extender performs an incremental search within the ListBox based on what has been typed so far.

ListSearchExtender Properties:

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

Code:

 <%-- ScriptManager control manages client script for AJAX enabled ASP.NET pages.This enables partial-page rendering and Web-service calls.You have to used this if you want to use ajax control--%>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<%--Use the ListSearchExtender here which control the ListBox1--%>
 
<cc1:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ListBox1">
</cc1:ListSearchExtender>
 
<asp:Label ID="Label1" runat="server"
Text="Click in ListBox and then write keyword to search" ForeColor="#009933"></asp:Label>
<br />
<%--Add the listbox control and set the selection mode properties like multiple--%>
 
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>Pak</asp:ListItem>
<asp:ListItem>Usa</asp:ListItem>
<asp:ListItem>Aus</asp:ListItem>
<asp:ListItem>Eng</asp:ListItem>
</asp:ListBox>

Here Item is added in ListBox.

Here TargetControlID is "ListBox1" this TextBox will be searchable.

 

Run the project

 

Ajax Toolkit ListSearchExtender Control in ASP.Net

When you write anything then if written keyword matches to the List box Item then it will highlight the matches’ value.

Ajax Toolkit ListSearchExtender Control in ASP.Net

 


Updated 07-Sep-2019

Leave Comment

Comments

Liked By