BulletedList — Click Event Alias & Migration Properties
The Click event alias and several selection properties support
Web Forms migration with minimal markup changes.
Click Event Alias (Interactive)
Both OnClick and Click can be used to handle item clicks in
LinkButton mode. Click matches the Web Forms event name for
easier migration. Click an item below to see it in action:
<BulletedList ItemType="object"
StaticItems="clickItems"
DisplayMode="BulletedListDisplayMode.LinkButton"
Click="HandleClick" />
@code {
private string clickMessage = "(none)";
private void HandleClick(BulletedListEventArgs e)
{
clickMessage = $"Clicked index {e.Index}: {clickItems[e.Index].Text}";
}
}
OnClick with SelectedIndex Tracking
Combine the OnClick event with SelectedIndex and
SelectedValue to track which item was last selected:
<BulletedList ItemType="object"
StaticItems="trackingItems"
DisplayMode="BulletedListDisplayMode.LinkButton"
OnClick="HandleTrackingClick" />
<p>SelectedIndex: @trackingIndex | SelectedValue: @trackingValue</p>
@code {
private int trackingIndex = -1;
private string trackingValue = "(none)";
private void HandleTrackingClick(BulletedListEventArgs e)
{
trackingIndex = e.Index;
trackingValue = trackingItems[e.Index].Value;
}
}
Migration Compatibility Properties
The following properties are accepted for Web Forms markup compatibility. They allow migrated markup to compile without changes, but do not produce visible behavior in Blazor. This is by design — Blazor’s event model replaces postback mechanics.
- Apple
- Banana
- Cherry
All migration stubs accepted: AutoPostBack, Text, SelectedIndex, SelectedValue
<!-- These attributes compile cleanly after migration -->
<BulletedList ItemType="object"
StaticItems="items"
AutoPostBack="true"
Text="My Fruit List"
SelectedIndex="1"
SelectedValue="banana"
SelectedIndexChanged="HandleChanged"
TextChanged="HandleTextChanged" />
Properties Reference
| Property / Event | Type | Default | Description |
|---|---|---|---|
Click | EventCallback<BulletedListEventArgs> | — | Web Forms event alias for OnClick — interactive |
SelectedIndex | int | -1 | Index of the selected item (migration stub) |
SelectedValue | string | null | Value of the selected item (migration stub) |
AutoPostBack | bool | false | Migration stub — Blazor events fire immediately |
Text | string | null | Text caption for the control (migration stub) |
SelectedIndexChanged | EventCallback<EventArgs> | — | Migration stub — accepted but not fired |
TextChanged | EventCallback<EventArgs> | — | Migration stub — accepted but not fired |