LinkButton.Click Evento

Definição

Ocorre quando um usuário clica no controle LinkButton.

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

Tipo de evento

Implementações

Exemplos

O exemplo a seguir demonstra como especificar e codificar um manipulador para o Click evento exibir uma mensagem quando o LinkButton controle for clicado.

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

Comentários

O Click evento é gerado quando o LinkButton controle é clicado. Esse evento geralmente é usado quando nenhum nome de comando está associado ao LinkButton controle, como no caso de um botão Enviar.

Para obter mais informações sobre como lidar com eventos, consulte Manipulando e levantando eventos.

Aplica-se a

Confira também