BulletedListEventHandler 대리자

정의

ClickBulletedList 이벤트를 처리할 메서드를 나타냅니다.

public delegate void BulletedListEventHandler(System::Object ^ sender, BulletedListEventArgs ^ e);
public delegate void BulletedListEventHandler(object sender, BulletedListEventArgs e);
type BulletedListEventHandler = delegate of obj * BulletedListEventArgs -> unit
Public Delegate Sub BulletedListEventHandler(sender As Object, e As BulletedListEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
BulletedListEventArgs

이벤트 데이터가 들어 있는 BulletedListEventArgs 형식의 인수입니다.

예제

다음 예제에는 지정 하 고 이벤트 처리기를 코딩 하는 방법을 보여 줍니다.는 Click 의 이벤트는 BulletedList 제어 합니다. 목록 항목을 클릭 하면 메시지에 표시 됩니다는 Label 페이지의 컨트롤입니다.

<%@ Page Language="C#" %>

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

    void ItemsBulletedList_Click(object sender, System.Web.UI.WebControls.BulletedListEventArgs e)
    {

        // Change the message displayed in the label based on the index
        // of the list item that was clicked.
        switch (e.Index) 
      {
            case 0:
                Message.Text = "You clicked list item 1.";
                break;
            case 1:
                Message.Text = "You clicked list item 2.";
                break;
            case 2:
                Message.Text = "You clicked list item 3.";
                break;
            default:
                throw new Exception("You did not click a valid list item.");
                break;
        }

    }

  </script>

</head>
<body>

  <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" 
      BulletStyle="Disc"
      DisplayMode="LinkButton" 
      OnClick="ItemsBulletedList_Click"
      runat="server">    
        <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:BulletedList>
            
    <asp:Label id="Message" 
      Font-Size="12"
      Width="168px" 
      Font-Bold="True" 
      runat="server"
      AssociatedControlID="ItemsBulletedList"/>
              
   </form>

</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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

    </script>

</head>
<body>

  <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" 
      BulletStyle="Disc"
      DisplayMode="LinkButton" 
      OnClick="ItemsBulletedList_Click"
      runat="server">    
        <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:BulletedList>
            
    <asp:Label id="Message" 
      Font-Size="12"
      Width="168px" 
      Font-Bold="True" 
      runat="server"
      AssociatedControlID="ItemsBulletedList"/>
              
   </form>

</body>
</html>

설명

만들 때를 BulletedListEventHandler 대리자를 처리할 메서드를 식별 합니다 Click 의 이벤트를 BulletedList 컨트롤입니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보