YouTip LogoYouTip

Prop Webcontrol Listitem Enabled

## ASP.NET ListItem Enabled Property The `Enabled` property is a member of the `ListItem` control in ASP.NET. It is used to specify or determine whether an individual list item within a list control (such as `ListBox`, `DropDownList`, `RadioButtonList`, or `CheckBoxList`) is enabled or disabled. --- ## Definition and Usage The `Enabled` property sets or returns a Boolean value indicating whether the `ListItem` is active and selectable by the user. * **True (Default):** The list item is enabled and can be selected or interacted with by the user. * **False:** The list item is disabled. It appears dimmed (grayed out) in the browser and cannot be selected or clicked by the user. --- ## Syntax ```xml ``` --- ## Code Example The following example demonstrates how to disable a specific `ListItem` within a `ListBox` control by setting its `Enabled` property to `False`. ```xml
``` --- ## Technical Considerations ### 1. Browser Compatibility and Rendering When `Enabled="False"` is set on a `ListItem`, ASP.NET renders the corresponding HTML element (typically an ` ``` Modern web browsers automatically style disabled options as grayed out and prevent users from selecting them. ### 2. Parent Control Override If the parent list control (e.g., `` or ``) has its own `Enabled` property set to `False`, the entire control is disabled. In this scenario, all child `ListItem` controls will be disabled regardless of their individual `Enabled` property settings. ### 3. Programmatic Access (C#) You can also dynamically enable or disable list items in your code-behind file: ```csharp // Disabling the first item in a DropDownList programmatically MyDropDownList.Items.Enabled = false; // Enabling the second item programmatically MyDropDownList.Items.Enabled = true; ```
← Prop Webcontrol Literal TextProp Webcontrol Linkbutton Val β†’