이 문서는 기계 번역을 이용하여 번역되었습니다. 문서를 영문으로 보려면 영문 확인란을 선택하세요. 마우스 포인터를 텍스트 위로 이동시켜 팝업 창에서 영문 텍스트를 표시할 수도 있습니다.
번역
영문

BulletedList.Click 이벤트

 

게시 날짜: 2016년 11월

BulletedList 컨트롤의 링크 단추를 클릭하면 발생합니다.

네임스페이스:   System.Web.UI.WebControls
어셈블리:  System.Web(System.Web.dll에 있음)

public event BulletedListEventHandler Click

The E:System.Web.UI.WebControls.BulletedList.Click event is raised when a list item in a T:System.Web.UI.WebControls.BulletedList control is clicked. To enable list items in a T:System.Web.UI.WebControls.BulletedList control to raise the E:System.Web.UI.WebControls.BulletedList.Click event, the P:System.Web.UI.WebControls.BulletedList.DisplayMode property first must be set to the value F:System.Web.UI.WebControls.BulletedListDisplayMode.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 E:System.Web.UI.WebControls.BulletedList.Click event of a T:System.Web.UI.WebControls.BulletedList control. When a list item is clicked, a message is displayed in a T:System.Web.UI.WebControls.Label control on the page. All the link buttons in the bulleted list raise the same E:System.Web.UI.WebControls.BulletedList.Click event. To determine which link button raised the event, the T:System.Web.UI.WebControls.BulletedListEventArgs argument is examined.

<%@ 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>

.NET Framework
2.0 이후 사용 가능
맨 위로 이동
표시: