BulletedList.Click Event


Occurs when a link button in a BulletedList control is clicked.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Public Event Click As BulletedListEventHandler

The Click event is raised when a list item in a BulletedList control is clicked. To enable list items in a BulletedList control to raise the Click event, the DisplayMode property first must be set to the value LinkButton.

Raising an event invokes the event handler through a delegate. For more information about handling events, see NIB: Consuming Events.

The following code example demonstrates how to specify and code an event handler for the Click event of a BulletedList control. When a list item is clicked, a message is displayed in a Label control on the page. All the link buttons in the bulleted list raise the same Click event. To determine which link button raised the event, the BulletedListEventArgs argument is examined.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>BulletedList Click Example</title>
  <script runat="server">

    Sub ItemsBulletedList_Click(ByVal sender As Object, _
                                ByVal e As System.Web.UI.WebControls.BulletedListEventArgs)

      ' Change the message displayed in the label based on the index
      ' of the list item that was clicked.
      Select Case (e.Index)
        Case 0
          Message.Text = "You clicked list item 1."
        Case 1
          Message.Text = "You clicked list item 2."
        Case 2
          Message.Text = "You clicked list item 3."
        Case Else
          Throw New Exception("You did not click a valid list item.")
      End Select

    End Sub



  <h3>BulletedList Click Example</h3>

  <form id="form1" runat="server">

    <p>Click on an item in the list to raise the Click event.</p> 

    <asp:BulletedList id="ItemsBulletedList" 
        <asp:ListItem Value="http://www.cohowinery.com">Coho Winery</asp:ListItem>
        <asp:ListItem Value="http://www.contoso.com">Contoso, Ltd.</asp:ListItem>
        <asp:ListItem Value="http://www.tailspintoys.com">Tailspin Toys</asp:ListItem>

    <asp:Label id="Message" 



.NET Framework
Available since 2.0
Return to top