Introduction:
In this example iam going to explain how to use ListSearch extender Control in asp.net.
If you want to check all the example in my site please check this link Ajax all extenders examples and also you check my previous example Accordion panel extender example.
Description:
The ListSearchExtender lets you search for items in a ListBox or DropDownList by typing. The extender performs an incremental search within the ListBox based on what has been typed so far. The prompt message that gets displayed when you click the list can be customized along with its CSS class and position.
When Ever You Want to Use Ajax Controls in your website First you need Add.
AjaxControlToolkit reference to your application.
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="asp"
%>
You can Change TagPrefix Also,Some Exaples tagPrefix="ajax", tagPrefix="cc1",tagPrefix="asp"
And also you have to add Tool kit Scriptmanager Control under <Form> tag:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
Your aspx page:
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-bottom: 80px">
<asp:Label ID="Label1" runat="server"
Text="First Click
at listbox ,dropdownlist then select the Country"
Font-Bold="true"
ForeColor="Red"></asp:Label>
</div>
<div>
<asp:ToolkitScriptManager
ID="ToolkitScriptManager1"
runat="server">
</asp:ToolkitScriptManager>
<asp:ListBox ID="lstboxCountries"
runat="server">
<asp:ListItem>Afghanistan</asp:ListItem>
<asp:ListItem>Albania</asp:ListItem>
<asp:ListItem>American Samoa</asp:ListItem>
<asp:ListItem>Bahamas</asp:ListItem>
<asp:ListItem>Bahrain</asp:ListItem>
<asp:ListItem>Bangladesh</asp:ListItem>
<asp:ListItem>Cambodia</asp:ListItem>
<asp:ListItem>Cameroon </asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
<asp:ListItem>Denmark</asp:ListItem>
<asp:ListItem>Djibouti</asp:ListItem>
<asp:ListItem>Dominica</asp:ListItem>
</asp:ListBox>
<asp:ListSearchExtender
ID="ListSearchExtender1"
TargetControlID="lstboxCountries"
PromptText="Search
Country" PromptPosition="Top" QueryPattern="StartsWith" IsSorted="true"
PromptCssClass="PromptCSSClass"
runat="server">
</asp:ListSearchExtender>
<asp:DropDownList ID="ddlCountries"
runat="server">
<asp:ListItem>Afghanistan</asp:ListItem>
<asp:ListItem>Albania</asp:ListItem>
<asp:ListItem>American Samoa</asp:ListItem>
<asp:ListItem>Bahamas</asp:ListItem>
<asp:ListItem>Bahrain</asp:ListItem>
<asp:ListItem>Bangladesh</asp:ListItem>
<asp:ListItem>Cambodia</asp:ListItem>
<asp:ListItem>Cameroon </asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
<asp:ListItem>Denmark</asp:ListItem>
<asp:ListItem>Djibouti</asp:ListItem>
<asp:ListItem>Dominica</asp:ListItem>
</asp:DropDownList>
<asp:ListSearchExtender
ID="ListSearchExtender2"
TargetControlID="ddlCountries"
PromptText="Search
Country"
PromptPosition="Top"
QueryPattern="StartsWith"
IsSorted="true"
PromptCssClass="PromptCSSClass"
runat="server">
</asp:ListSearchExtender>
</div>
</form>
</body>
</html>
|