Partilhar via


How to: Respond to User Clicks in BulletedList Web Server Controls

You can configure a BulletedList control to display LinkButton controls as the bulleted list items. When users click a button, the control posts the page back to the server and gives you an opportunity to run code in response to the click.

To respond to a user click in a BulletedList Web server control

  1. In Design view, double-click the BulletedList control and then add a handler for the BulletedList control's Click event.

  2. In the event handler, get the Index property of the BulletedListEventArgs value passed to the handler.

  3. Using the index, get the appropriate item from the control and then get the item's Text and Value properties.

Example

The following code example shows a Click event handler for a BulletedList control. The handler displays which list item the user clicked.

Protected Sub BulletedList1_Click(ByVal sender As Object, _
        ByVal e As System.Web.UI.WebControls.BulletedListEventArgs) _
        Handles BulletedList1.Click
    Dim position As Integer = e.Index
    Dim li As ListItem = BulletedList3.Items(position)
    Label1.Text = "You selected = " & li.Text & _ 
        ", with value = " & li.Value
End Sub
protected void BulletedList1_Click(object sender, 
    BulletedListEventArgs e)
{
    ListItem li = BulletedList1.Items[e.Index];
    Label1.Text = "You selected = " + li.Text + ", with value = " 
        + li.Value;
}

See Also

Concepts

BulletedList Web Server Control Overview