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:

Last click: (none)

<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:

SelectedIndex: -1  |  SelectedValue: (none)

<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.

  1. Apple
  2. Banana
  3. 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 / EventTypeDefaultDescription
ClickEventCallback<BulletedListEventArgs>Web Forms event alias for OnClickinteractive
SelectedIndexint-1Index of the selected item (migration stub)
SelectedValuestringnullValue of the selected item (migration stub)
AutoPostBackboolfalseMigration stub — Blazor events fire immediately
TextstringnullText caption for the control (migration stub)
SelectedIndexChangedEventCallback<EventArgs>Migration stub — accepted but not fired
TextChangedEventCallback<EventArgs>Migration stub — accepted but not fired