Skip to main content

How to use ListSearchExtender in asp.net ajax


ListSearchExtender



ListSearchExtender is an asp.net ajax control toolkit's extender control. ListSearchExtender control can be extend asp.net
ListBox and DropDownList web server controls. ListSearchExtender control allow us to search for items in an extended ListBox or
DropDownList server control by typing. ListSearchExtender control provide an incremental search within the ListBox based on what has been
typed so far.




ListSearchExtender control have the following properties those are TargetControlID, PromptText, PromptCssClass, PromptPosition,
QueryPattern, IsSorted, QueryTimeout, Animations, OnShow, OnShowBehavior, OnHide, OnHideBehavior and raiseImmediateOnChange.




ListSearchExtender control's TargetControlID specify the asp.net ListBox or DropDownList control which we want to provide items
search facility. PromptText property set a message to display when the target control get focus. PromptCssClass allow us to design
prompt message using css style. PromptPosition property set the position of prompt message in target ListBox or DropDownList control.
PromptPosition property value can be Top or Bottom and default value is Top.




QueryPattern property specify how the typed characters should be used in the search query. default query pattern is StartsWith that means
results starts with the typed word. QueryPattern property another value is Contains.




QueryTimeout property indicate whether the search query should be reset after the timeout if no match is found. default value
is 0 that means no auto reset behavior. IsSorted property indicate if items added to the list are expected to be sorted.




Animations property allow us to apply generic animations for the ListSearchExtender. OnShow ensure animation will be played
each time the prompt is displayed and OnHide ensure animation will be played each time prompt message is hidden.




raiseImmediateOnChange property indicate whether an OnChange event should be fired as soon as the selected element is changed, when
the list loses focus or user hits enter.




ListSearchExtender control have the following methods those are initialize(), dipose(), OnShow() and OnHide(). OnShow()
method play the OnShow animation and OnHide() method play the OnHide animation.




UsingListSearchExtender.aspx



<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
string[] colorList = Enum.GetNames(typeof(KnownColor));
ListBox1.DataSource = colorList;
ListBox1.DataBind();
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Ajax ListSearchExtender - How to use ListSearchExtender in asp.net ajax</title>
<style type="text/css">
.PromptCSS
{
color:DodgerBlue;
font-size:large;
font-style:italic;
font-weight:bold;
background-color:AliceBlue;
height:25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using ListSearchExtender</h2>
<hr width="550" align="left" color="LawnGreen" />
<asp:ScriptManager
ID="ScriptManager1"
runat="server"
>
</asp:ScriptManager>
<cc1:ListSearchExtender
ID="ListSearchExtender1"
runat="server"
TargetControlID="ListBox1"
PromptCssClass="PromptCSS"
>
</cc1:ListSearchExtender>
<br /><br />
<asp:ListBox
ID="ListBox1"
runat="server"
BackColor="Pink"
ForeColor="DeepPink"
Font-Size="Medium"
Font-Bold="true"
Height="250"
>
</asp:ListBox>
</div>
</form>
</body>
</html>
















Popular posts from this blog

Restricting Jetpack Compose TextField to Numeric Input Only

Jetpack Compose has revolutionized Android development with its declarative approach, enabling developers to build modern, responsive UIs more efficiently. Among the many components provided by Compose, TextField is a critical building block for user input. However, ensuring that a TextField accepts only numeric input can pose challenges, especially when considering edge cases like empty fields, invalid characters, or localization nuances. In this blog post, we'll explore how to restrict a Jetpack Compose TextField to numeric input only, discussing both basic and advanced implementations. Why Restricting Input Matters Restricting user input to numeric values is a common requirement in apps dealing with forms, payment entries, age verifications, or any data where only numbers are valid. Properly validating input at the UI level enhances user experience, reduces backend validation overhead, and minimizes errors during data processing. Compose provides the flexibility to implement ...

jetpack compose - TextField remove underline

Compose TextField Remove Underline The TextField is the text input widget of android jetpack compose library. TextField is an equivalent widget of the android view system’s EditText widget. TextField is used to enter and modify text. The following jetpack compose tutorial will demonstrate to us how we can remove (actually hide) the underline from a TextField widget in an android application. We have to apply a simple trick to remove (hide) the underline from the TextField. The TextField constructor’s ‘colors’ argument allows us to set or change colors for TextField’s various components such as text color, cursor color, label color, error color, background color, focused and unfocused indicator color, etc. Jetpack developers can pass a TextFieldDefaults.textFieldColors() function with arguments value for the TextField ‘colors’ argument. There are many arguments for this ‘TextFieldDefaults.textFieldColors()’function such as textColor, disabledTextColor, backgroundColor, cursorC...

jetpack compose - Image clickable

Compose Image Clickable The Image widget allows android developers to display an image object to the app user interface using the jetpack compose library. Android app developers can show image objects to the Image widget from various sources such as painter resources, vector resources, bitmap, etc. Image is a very essential component of the jetpack compose library. Android app developers can change many properties of an Image widget by its modifiers such as size, shape, etc. We also can specify the Image object scaling algorithm, content description, etc. But how can we set a click event to an Image widget in a jetpack compose application? There is no built-in property/parameter/argument to set up an onClick event directly to the Image widget. This android application development tutorial will demonstrate to us how we can add a click event to the Image widget and make it clickable. Click event of a widget allow app users to execute a task such as showing a toast message by cli...