LinkButton.OnClick(EventArgs) 메서드

정의

Click 컨트롤의 LinkButton 이벤트를 발생시킵니다.

protected:
 virtual void OnClick(EventArgs ^ e);
protected virtual void OnClick (EventArgs e);
abstract member OnClick : EventArgs -> unit
override this.OnClick : EventArgs -> unit
Protected Overridable Sub OnClick (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터를 포함하는 EventArgs입니다.

예제

다음 예제에서는 지정 하 고 클릭 하는 컨트롤을 표시 하는 이벤트에 대 한 Click 처리기를 코딩 하는 LinkButton 방법을 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>
    <title>LinkButton Example</title>
<script language="C#" runat="server">
 
      void LinkButton_Click(Object sender, EventArgs e) 
      {
         Label1.Text="You clicked the link button";
      }
 
   </script>
 
</head>
<body>
 
   <form id="form1" runat="server">

      <h3>LinkButton Example</h3>
 
      <asp:LinkButton id="LinkButton1" 
           Text="Click Me" 
           Font-Names="Verdana" 
           Font-Size="14pt" 
           OnClick="LinkButton_Click" 
           runat="server"/>
         
      <br />
 
      <asp:Label id="Label1" runat="server" />
         
   </form>
 
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>
    <title>LinkButton Example</title>
<script language="VB" runat="server">
 
      Sub LinkButton_Click(sender As Object, e As EventArgs) 
         Label1.Text = "You clicked the link button"
      End Sub
 
   </script>
 
</head>
<body>
 
   <form id="form1" runat="server">

      <h3>LinkButton Example</h3>
 
      <asp:LinkButton id="LinkButton1" 
           Text="Click Me" 
           Font-Names="Verdana" 
           Font-Size="14pt" 
           OnClick="LinkButton_Click" 
           runat="server"/>
         
      <br />
 
      <asp:Label id="Label1" runat="server" />
         
   </form>
 
</body>
</html>

설명

Click 컨트롤을 클릭할 때 LinkButton 이벤트가 발생합니다. 이 이벤트는 전송 단추의 경우와 같이 컨트롤과 LinkButton 연결된 명령 이름이 없는 경우에 일반적으로 사용됩니다.

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생합니다.

또한 OnClick 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

상속자 참고

파생 클래스에서 OnClick(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnClick(EventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보