BulletedListEventHandler 代理人

定義

Click コントロールの BulletedList イベントを処理するメソッドを表します。

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作成するときは、コントロールのイベントを処理するメソッドをClickBulletedList識別します。 イベント ハンドラーにイベントを関連付けるには、イベントにデリゲートのインスタンスを追加します。 イベント ハンドラーは、デリゲートを削除しない限り、イベントが発生するたびに呼び出されます。 イベント ハンドラー デリゲートの詳細については、「イベントの 処理と発生」を参照してください。

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください