$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ListBox Items in ASP.NET
Home > How to > ListBox Items

How to customize the settings of the listbox items in ASP.NET web application? This article aims to answer this question with detailed programming example. The whole tutorial page is divided into two main parts. In the first part, we will list all the supported item properties and in the second part, we will show developers how to define listbox items using aspx code.

Supported Properties of ListBox Items

The PerListBox control for ASP.NET AJAX offers a comprehensive list of properties for developers to have a full control over the settings of each item contained in the listbox. And in this section, we will briefly illustrate the functions of all the supported item properties.
Text property controls the string that appears on the item in the list.
  • Value property refers to the value associated with item.
  • Checked property determines whether the item is checked or not.
  • Checkable property determines whether the item can be checked or not.
  • AllowDrag property is used to define whether the item can be dragged or not.
  • ToolTip property refers to the text string that appears on the item when the mouse is over the item.
  • Selected property determines whether the item is selected or not.
  • Enabled property determines whether the item can be selected or not.
  • ImageUrl property is used to define the image path when you need to add an image to the item.
  • BorderStyle property allows developers to set the border (which appears when the item is selected) to solid or dashed or other styles.
  • BorderColor property refers to the item background color when it is selected.
  • BorderWidth property controls the width of the border which appears when the item is selected.

How to Declare ListBox Items Inline

In this section, we will provide a sample programming code to guide you on how to define the listbox items in aspx file.
<kettic:PerListBox runat="server" ID="PerListBox1" Height="200px" 
Width="200px" Skin="Forest" >
<kettic:PerListBoxItem Text="PerListBoxItem1" />
<kettic:PerListBoxItem Text="PerListBoxItem2" />
<kettic:PerListBoxItem Text="PerListBoxItem3" Selected="true" />
<kettic:PerListBoxItem Text="PerListBoxItem4" />
Here we attach an image to represent the result of above asp.net listitem definition application.
Note: the number of items in the PerListBox control is not limited and developers can easily load items from other data storage files to the PerListBox control. Besides, it is an extremely easy task to add, delete and modify the items in the listbox.