Class ListBox
The ListBox control provides a list of options for users to select from. It is capable of including other HTML elements such as images, text boxes, check boxes, and radio buttons and so on.
Implements
Inherited Members
Namespace: Syncfusion.JavaScript.Web
Assembly: Syncfusion.EJ.Web.dll
Syntax
public class ListBox : CommonDataBoundControl, INamingContainer, IPostBackEventHandler, IPostBackDataHandler, IUrlResolutionService
Constructors
ListBox()
Declaration
public ListBox()
Properties
AllowDrag
Specifies whether to Enables/disables the dragging behavior of the items in ListBox widget.
Declaration
public bool AllowDrag { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
AllowDragAndDrop
Specifies whether to Enable/disable the drag/drop behavior of the items in ListBox widget.
Declaration
public bool AllowDragAndDrop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
AllowDrop
Specifies whether to Accepts the items which are dropped in to it, when it is set to true.
Declaration
public bool AllowDrop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
AllowMultiSelection
Specifies whether to Enables or disables multiple selection.
Declaration
public bool AllowMultiSelection { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
AllowVirtualScrolling
Specifies whether to Loads the list data on demand via scrolling behavior to improve the application’s performance.
Declaration
public bool AllowVirtualScrolling { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CascadeTo
Specifies dynamically populate data of a list box while selecting an item in another list box i.e. rendering child list box based on the item selection in parent list box.
Declaration
public string CascadeTo { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
CaseSensitiveSearch
Specifies whether to Enables or disables the case sensitive search for list item by typing the text (search) value.
Declaration
public bool CaseSensitiveSearch { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CheckAll
Specifies whether to Check all the list items in the ListBox widget. It is dependent on showCheckbox property.
Declaration
public bool CheckAll { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
checkedIndices
Set of list items to be checked by default using its index. It works only when the showCheckbox property is set to true.
Declaration
public List<int> checkedIndices { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
CheckedItemList
Specifies the CheckedItemlist for the ListBox.
Declaration
public List<int> CheckedItemList { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
CheckedItems
Specifies the items to be a checked in the ListBox.
Declaration
public List<int> CheckedItems { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
CheckItemsByIndex
Checks a list item by using its index value.
Declaration
public string CheckItemsByIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnActionBegin
Triggers before the AJAX request begins to load data in the ListBox widget.
Declaration
public string ClientSideOnActionBegin { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnActionComplete
Triggers when the AJAX requests complete. The request may get failed or succeed.
Declaration
public string ClientSideOnActionComplete { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnActionFailure
Triggers when the data requested from AJAX get failed.
Declaration
public string ClientSideOnActionFailure { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnActionSuccess
Triggers after the data requested via AJAX is successfully loaded in the ListBox widget. ///
Declaration
public string ClientSideOnActionSuccess { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnCascade
Triggers when cascading action performs in listbox.
Declaration
public string ClientSideOnCascade { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnChange
Triggers when the item selection is changed.
Declaration
public string ClientSideOnChange { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnCheckChange
Triggers when the list item is checked or unchecked.
Declaration
public string ClientSideOnCheckChange { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnCreate
Triggers when the ListBox widget is created successfully.
Declaration
public string ClientSideOnCreate { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnDestroy
Triggers when the ListBox widget is destroyed successfully.
Declaration
public string ClientSideOnDestroy { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemDrag
Triggers when the list item is being dragged.
Declaration
public string ClientSideOnItemDrag { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemDragStart
Triggers when the list item drag starts.
Declaration
public string ClientSideOnItemDragStart { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemDragStop
Triggers when the list item stops dragging.
Declaration
public string ClientSideOnItemDragStop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemDrop
Triggers when the list item is dropped.
Declaration
public string ClientSideOnItemDrop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemDropped
Triggers when the list item is dropped.
Declaration
public string ClientSideOnItemDropped { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnItemRequest
Fires when item request is successful.
Declaration
public string ClientSideOnItemRequest { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnSelect
Triggers when a list item gets selected.
Declaration
public string ClientSideOnSelect { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnSelected
Triggers when a list item gets selected.
Declaration
public string ClientSideOnSelected { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnSelectIndexChanged
Triggers when Selected Index is Changed.
Declaration
public string ClientSideOnSelectIndexChanged { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ClientSideOnUnselect
Triggers when a list item gets unselected.
Declaration
public string ClientSideOnUnselect { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
CssClass
Specifies the root class for the ListBox widget to customize the existing theme.
Declaration
public string CssClass { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataCategory
Mapping Field for Category property.
Declaration
public string DataCategory { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataCheckByField
Mapping Field for CheckBy property.
Declaration
public string DataCheckByField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataGroupBy
Mapping Field for groupby property.
Declaration
public string DataGroupBy { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataHtmlAttributesField
Mapping Field for htmlAttributes property.
Declaration
public string DataHtmlAttributesField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataIdField
Mapping Field for id property
Declaration
public string DataIdField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataImageAttributesField
Mapping Field for Parent Id property.
Declaration
public string DataImageAttributesField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataImageUrlField
Mapping Field for Image url property.
Declaration
public string DataImageUrlField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataManager
Data Manager as Inner property, which help us to bind the data sources from data adaptors
Declaration
public DataSource DataManager { get; set; }
Property Value
| Type | Description |
|---|---|
| DataSource |
DataSelectByField
Mapping Field for SelectBy property.
Declaration
public string DataSelectByField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataSelectedField
Mapping Field for selected property.
Declaration
public string DataSelectedField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataSource
Contains the list of data for generating the list items.
Declaration
public object DataSource { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Object |
DataSourceCachingMode
Specifies the Data Source object will be serialized and added to the View State. So, no need to initialize the Data Source after each and every postback.
Declaration
public DataSourceCachingMode DataSourceCachingMode { get; set; }
Property Value
| Type | Description |
|---|---|
| DataSourceCachingMode |
DataSpriteCSSField
Mapping Field for spriteCss property.
Declaration
public string DataSpriteCSSField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataTableNameField
Mapping Field for imageAttributes property.
Declaration
public string DataTableNameField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataTextField
Mapping Field for text property.
Declaration
public string DataTextField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataTooltipTextField
Mapping Field for TooltipText property.
Declaration
public string DataTooltipTextField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataValueField
Mapping Field for Value property.
Declaration
public string DataValueField { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DisableItemsByIndex
Disables a list Item using its index value.
Declaration
public string DisableItemsByIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
EmptyDataText
Specifies the error message for listbox.
Declaration
public string EmptyDataText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Enabled
Specifies whether Enables or disables the ListBox widget.
Declaration
public bool Enabled { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnableIncrementalSearch
Specifies whether to Enables or disables the search behavior to find the specific list item by typing the text value.
Declaration
public bool EnableIncrementalSearch { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnableItemsByIndex
Enables a set of list Items using its index values.
Declaration
public string EnableItemsByIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
EnableLoadOnDemand
EnableLoadOnDemand has been deprecated.Use the 'AllowVirtualScrolling' property to achieve this behavior.
Declaration
[Obsolete("EnableLoadOnDemand has been deprecated. Use AllowVirtualScrolling property ")]
public bool EnableLoadOnDemand { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnablePersistence
Specifies whether to Allows the current model values to be saved in local storage or browser cookies for state maintenance when it is set to true.
Declaration
public bool EnablePersistence { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnableRTL
Specifies the ListBox widget’s content from right to left when enabled.
Declaration
public bool EnableRTL { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnableVirtualScrolling
EnableVirtualScrolling has been deprecated. Use 'VirtualScrollMode=VirtualScrollMode.Normal' property to achieve this behavior.
Declaration
[Obsolete("EnableVirtualScrolling has been deprecated. Use VirtualScrollMode property ")]
public bool EnableVirtualScrolling { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
EnableWordWrap
Disable default wordwrap of the listbox text with the help of this property.
Declaration
public bool EnableWordWrap { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Height
Specifies the height of the ListBox widget.
Declaration
public string Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ItemHeight
Specifies the itemHeight of the ListBox widget.
Declaration
public string ItemHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ItemRequestCount
specifies the number of list items to be loaded in the list box while enabling virtual scrolling and when virtualScrollMode is set to continuous.
Declaration
public int ItemRequestCount { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Items
Specifies the Collection of items.
Declaration
public List<ListBoxItems> Items { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<ListBoxItems> |
ItemsCount
Specifies the number of list items to be shown in the ListBox widget. The remaining list items will be scrollable.
Declaration
public int ItemsCount { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ListBoxFields
Specifies the Collection of ListBoxFields.
Declaration
public ListBoxFields ListBoxFields { get; }
Property Value
| Type | Description |
|---|---|
| ListBoxFields |
LoadDataOnInit
Specifies whether to Loads data for the listbox by default (i.e. on initialization) when it is set to true. It creates empty ListBox if it is set to false.
Declaration
public bool LoadDataOnInit { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Model
Collection of ListBox model items.
Declaration
public ListBoxProperties Model { get; set; }
Property Value
| Type | Description |
|---|---|
| ListBoxProperties |
Query
Specifies the query to retrieve required data from the data source.
Declaration
public string Query { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
SelectedIndex
Specifies the list item to be selected by default using its index.
Declaration
public int? SelectedIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
selectedIndices
The list items to be selected by default using its indices. To use this property allowMultiSelection should be enabled.
Declaration
public List<int> selectedIndices { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
SelectedItemIndex
Specifies the SelectedItemIndex for the ListBox.
Declaration
public int? SelectedItemIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
selectedItemlist
Specifies the SelectedItems for the ListBox.
Declaration
public List<int> selectedItemlist { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
SelectedItems
Returns the list of selected items in the ListBox widget.
Declaration
public List<int> SelectedItems { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Int32> |
ShowCheckbox
Specifies Enables/Disables the multi selection option with the help of checkbox control.
Declaration
public bool ShowCheckbox { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ShowRoundedCorner
Specifies whether to display the ListBox container with rounded corners.
Declaration
public bool ShowRoundedCorner { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
SortOrder
Gets or sets the Sorting Type.
Declaration
public SortOrder SortOrder { get; set; }
Property Value
| Type | Description |
|---|---|
| SortOrder | The sortingTpe. |
TargetID
Specifies the targetID for the listbox items.
Declaration
public string TargetID { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Template
Specifies the template to display the ListBox widget with customized appearance.
Declaration
public string Template { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Text
Defines the text of the ListBox.
Declaration
public string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
TotalItemsCount
Specifies the total number of list items to be rendered in the ListBox widget.
Declaration
public int TotalItemsCount { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
UncheckAll
Specifies whether to Uncheck all the checked list items in the ListBox widget. To use this method showCheckbox property to be set as true.
Declaration
public bool UncheckAll { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
UncheckItemsByIndex
Unchecks the checked list item using its index value. To use this method showCheckbox property to be set as true.
Declaration
public string UncheckItemsByIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Value
Defines the Value of the ListBox.
Declaration
public string Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
VirtualScrollMode
Specifies the virtual scroll mode to load the list data on demand via scrolling behavior.
Declaration
public VirtualScrollMode VirtualScrollMode { get; set; }
Property Value
| Type | Description |
|---|---|
| VirtualScrollMode |
Width
Specifies the Width of the ListBox widget.
Declaration
public string Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
ClearSelection()
Method to clear values
Declaration
public void ClearSelection()
DependentScripts()
Get the dependent script for ListBox control
Declaration
public List<string> DependentScripts()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> |
FetchData(IEnumerable)
Fetching the data
Declaration
public override void FetchData(IEnumerable data)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | data |
Overrides
GetDependentFiles()
Get the dependent files for ListBox control
Declaration
public override List<string> GetDependentFiles()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> |
Overrides
LoadViewState(Object)
Restores view-state information from a previous page request.
Declaration
protected override void LoadViewState(object state)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | state |
Overrides
OnLoad(EventArgs)
Raises the Load event.
Declaration
protected override void OnLoad(EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e |
Overrides
PostBackEventHandler(String, Dictionary<String, Object>)
Gets a value that indicates whether the page is being loaded in response to a postback.
Declaration
public override void PostBackEventHandler(string EventName, Dictionary<string, object> args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | EventName | |
| System.Collections.Generic.Dictionary<System.String, System.Object> | args |
Overrides
Render()
Render this instance
Declaration
public string Render()
Returns
| Type | Description |
|---|---|
| System.String |
Render(HtmlTextWriter)
Declaration
protected override void Render(HtmlTextWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.UI.HtmlTextWriter | writer |
Overrides
SaveViewState()
Saves any server control view-state changes that have occurred since the time the page was posted back to the server.
Declaration
protected override object SaveViewState()
Returns
| Type | Description |
|---|---|
| System.Object |
UpdateServerModel(Dictionary<String, Object>)
Maintaining viewstate model values on post back
Declaration
public override void UpdateServerModel(Dictionary<string, object> ClientModel)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<System.String, System.Object> | ClientModel |
Overrides
Events
CheckChange
Triggered when the check value is changed.
Declaration
public event ListBox.ListBoxEventHandler CheckChange
Event Type
| Type | Description |
|---|---|
| ListBox.ListBoxEventHandler |
IndexChanged
Triggered when the index of the listbox gets changed.
Declaration
public event ListBox.ListBoxEventHandler IndexChanged
Event Type
| Type | Description |
|---|---|
| ListBox.ListBoxEventHandler |
ItemDrop
Triggered when the item is dropped to the listbox.
Declaration
public event ListBox.ListBoxEventHandler ItemDrop
Event Type
| Type | Description |
|---|---|
| ListBox.ListBoxEventHandler |
ValueSelect
Triggered when the value is selected.
Declaration
public event ListBox.ListBoxEventHandler ValueSelect
Event Type
| Type | Description |
|---|---|
| ListBox.ListBoxEventHandler |