LinkButton.Click 事件

定义

在单击 LinkButton 控件时发生。

public:
 event EventHandler ^ Click;
public:
 virtual event EventHandler ^ Click;
public event EventHandler Click;
member this.Click : EventHandler 
Public Custom Event Click As EventHandler 

事件类型

实现

示例

下面的示例演示如何为 事件指定和编码处理程序, 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 控件关联时,通常使用此事件,例如“提交”按钮的情况。

有关如何处理事件的详细信息,请参阅 处理和引发事件

适用于

另请参阅