YouTip LogoYouTip

Prop Webcontrol Bulletedlist Displaymode

## ASP.NET BulletedList DisplayMode Property The `DisplayMode` property is a key feature of the ASP.NET `BulletedList` web control. It allows developers to define how the list items are rendered and how they behave when clicked. --- ## Definition and Usage The `DisplayMode` property gets or sets the display behavior of the list items within a `BulletedList` control. By default, list items are rendered as plain text, but they can easily be configured to act as hyperlinks or postback link buttons. --- ## Syntax ```xml ``` ### Property Values | Value | Description | | :--- | :--- | | `Text` | **Default.** Renders the list items as standard, non-interactive text. | | `HyperLink` | Renders the list items as hyperlinks (`` tags). Clicking an item navigates the user to the URL specified in the item's `Value` property. | | `LinkButton` | Renders the list items as link buttons. Clicking an item triggers a postback to the server, raising the `Click` event of the `BulletedList` control. | --- ## Code Examples ### Example 1: Rendering List Items as Hyperlinks (`HyperLink` Mode) In this mode, the `Text` property of each `ListItem` is displayed as the link text, and the `Value` property acts as the destination URL (`href`). ```xml <%@ Page Language="C#" %> BulletedList DisplayMode HyperLink Example

Useful Developer Resources

``` ### Example 2: Handling Server-Side Clicks (`LinkButton` Mode) When using `LinkButton` mode, clicking an item posts the page back to the server. You can handle the click event using the `OnClick` event handler of the `BulletedList` control. ```xml <%@ Page Language="C#" %> BulletedList DisplayMode LinkButton Example

Select a Category


``` --- ## Considerations and Best Practices 1. **Target Attribute with HyperLink Mode:** When using `DisplayMode="HyperLink"`, you can use the `Target` property of the `BulletedList` control (e.g., `Target="_blank"`) to specify where the linked document should open. 2. **Event Handling with LinkButton Mode:** When using `DisplayMode="LinkButton"`, ensure you implement the `OnClick` event handler. The event argument (`BulletedListEventArgs`) provides an `Index` property, which you can use to determine which specific item was clicked. 3. **Validation:** If your page relies on ASP.NET validation controls, remember that `LinkButton` mode triggers a page postback, which will trigger client-side and server-side validation by default.
← Prop Webcontrol Bulletedlist FProp Webcontrol Bulletedlist B β†’