Export (0) Print
Expand All

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.

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

protected void BulletedList1_Click(object sender, 
    BulletedListEventArgs e)
{
    ListItem li = BulletedList1.Items[e.Index];
    Label1.Text = "You selected = " + li.Text + ", with value = " 
        + li.Value;
}

Community Additions

ADD
Show:
© 2014 Microsoft