System.Web
1.0.5000.0
2.0.0.0
Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.
System.Web.UI.WebControls.ListControl
System.Web.UI.IPostBackDataHandler
System.Web.UI.SupportsEventValidation
System.Web.UI.ValidationProperty("SelectedItem")
In this topic:
-
Introduction
-
Accessibility
-
Declarative Syntax
Introduction
Use the control to create a list control that allows single or multiple item selection. Use the property to specify the height of the control. To enable multiple item selection, set the property to ListSelectionMode.Multiple.
To specify the items that you want to appear in the control, place a ListItem element for each entry between the opening and closing tags of the control.
Use the collection to examine the objects contained in the control. For example, you can determine the selected item(s) in the control by enumerating the collection and testing the value for each element.
The control also supports data binding. To bind the control to a data source, first create a data source, such as one of the objects, that contains the items to display in the control. Next, use the method to bind the data source to the control. Use the and properties to specify which field in the data source to bind to the Text and Value properties, respectively, of each list item in the control. The control will now display the information from the data source.
This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see Securing Standard Controls, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Introduction to Validating User Input in ASP.NET Web Pages.
Accessibility
For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.
Declarative Syntax
<asp:ListBox
AccessKey="string"
AppendDataBoundItems="True|False"
AutoPostBack="True|False"
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
Inset|Outset"
BorderWidth="size"
CausesValidation="True|False"
CssClass="string"
DataMember="string"
DataSource="string"
DataSourceID="string"
DataTextField="string"
DataTextFormatString="string"
DataValueField="string"
Enabled="True|False"
EnableTheming="True|False"
EnableViewState="True|False"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
ID="string"
OnDataBinding="DataBinding event handler"
OnDataBound="DataBound event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnSelectedIndexChanged="SelectedIndexChanged event handler"
OnTextChanged="TextChanged event handler"
OnUnload="Unload event handler"
Rows="integer"
runat="server"
SelectedIndex="integer"
SelectedValue="string"
SelectionMode="Single|Multiple"
SkinID="string"
Style="string"
TabIndex="integer"
ToolTip="string"
ValidationGroup="string"
Visible="True|False"
Width="size"
>
<asp:ListItem
Enabled="True|False"
Selected="True|False"
Text="string"
Value="string"
/>
</asp:ListBox>
Represents a list box control that allows single or multiple item selection.
Constructor
Use this constructor to create and initialize a new instance of the class.
Initializes a new instance of the class.
1.0.5000.0
2.0.0.0
Method
System.Void
To be added
Adds name, size, multiple, and onchange to the list of attributes to render.
The output stream that renders HTML content to the client.
1.0.5000.0
2.0.0.0
Property
System.Drawing.Color
a
The property is inherited from the class and is not applicable to the control.
Gets or sets the border color of the control.
1.0.5000.0
2.0.0.0
System.ComponentModel.Browsable(false)
Property
System.Web.UI.WebControls.BorderStyle
a
The property is inherited from the class and is not applicable to the control.
Gets or sets the border style of the control.
1.0.5000.0
2.0.0.0
System.ComponentModel.Browsable(false)
Property
System.Web.UI.WebControls.Unit
a
The property is inherited from the class and is not applicable to the control.
Gets or sets the border width for the control.
1.0.5000.0
2.0.0.0
System.ComponentModel.Browsable(false)
Method
2.0.0.0
System.Int32[]
Use the method to identify or access the selected items in the control. Each element in the returned array represents the index for a selected list item. You can use the index values to access the items in the collection.
Gets the array of index values for currently selected items in the control.
An array of integers, each representing the index of a selected item in the list box.
Method
2.0.0.0
System.Boolean
The method is used primarily by control developers, when deriving a custom control from the class.
The method indicates if the state of the control has changed. In other words, it determines if each list item in the control has the same value as the last posted value. A user selecting an item in the control changes the value for the corresponding object in the collection of the control. If some list items are selected in the control, or if the is disabled, returns false.
When the method returns true for a control, the ASP.NET page framework invokes the method for the control.
Loads the posted content of the list control, if it is different from the last posting.
true if the posted content is different from the last posting; otherwise, false.
The key identifier for the control, used to index the .
A that contains value information indexed by control identifiers.
Method
System.Void
The method is used primarily by control developers, when deriving a custom control from the class. The method allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
The method performs any necessary prerendering steps prior to saving view state and rendering content for the .
Configures the control prior to rendering on the client.
An object that contains the event data.
1.0.5000.0
2.0.0.0
Method
2.0.0.0
System.Void
The method is used primarily by control developers, when deriving a custom control from the control.
The ASP.NET page framework calls the method on a control when the method indicates that the state of the list items have changed in the control. The method calls the method to raise the event. Control developers can override the method to perform custom processing when the user selects list items in the control.
The method can optionally perform validation before raising the event for the control. To validate a group of controls on the page when a list item within the is selected, set the and properties to true, and then specify the group of controls to validate in the property.
Invokes the method whenever posted data for the control has changed.
Method
System.Void
a
To be added
To be added
1.0.5000.0
Property
System.Int32
To be added: an object of type 'int'
Use the property to specify the number of rows to display in the control.
The number of rows must be between one and 2000. Values outside of this range will raise an exception.
The value of the property is stored in view state.
Gets or sets the number of rows displayed in the control.
1.0.5000.0
2.0.0.0
System.ComponentModel.DefaultValue(4)
Property
System.Web.UI.WebControls.ListSelectionMode
To be added: an object of type 'ListSelectionMode'
Use the property to specify the mode behavior of the control. Setting this property to ListSelectionMode.Single indicates only a single item can be selected from the control, while ListSelectionMode.Multiple specifies multiple items can be selected.
The value of the property is stored in view state.
Gets or sets the selection mode of the control.
1.0.5000.0
2.0.0.0
System.ComponentModel.DefaultValue(System.Web.UI.WebControls.ListSelectionMode.Single)
Method
1.0.5000.0
2.0.0.0
System.Boolean
Typically, you should use the method to process posted data for changes to a object.
The method is an explicit interface member implementation. It can be used only when the instance is cast to an interface.
Loads the posted content of the list control, if it is different from the last posting.
true if the posted content is different from the last posting; otherwise, false.
The index within the posted collection that references the content to load.
The collection posted to the server.
Method
1.0.5000.0
2.0.0.0
System.Void
Typically, you should use the method to raise an event when the posted data for a object changes.
The method is an explicit interface member implementation. It can be used only when the instance is cast to an interface.
Invokes the method whenever posted data for the control has changed.
Property
System.String
To be added
a
To be added
1.0.5000.0
2.0.0.0
System.ComponentModel.Localizable(true)
System.ComponentModel.DefaultValue("")
Method
2.0.0.0
System.Void
To be added.
To be added.