This documentation is archived and is not being maintained.

LinkButton.Click Event

Occurs when the LinkButton control is clicked.

[Visual Basic]
Public Event Click As EventHandler
[C#]
public event EventHandler Click;
[C++]
public: __event EventHandler* Click;

[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives an argument of type EventArgs.

Remarks

The Click event is raised when the LinkButton control is clicked. This event is commonly used when no command name is associated with the LinkButton control, such as a submit button.

For more information about handling events, see Consuming Events.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to specify and code a handle for the Click event to display a message when the LinkButton control is clicked.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>

   <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 runat=server>

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


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

   <script language="C#" runat="server">
 
      void LinkButton_Click(Object sender, EventArgs e) 
      {
         Label1.Text="You clicked the link button";
      }
 
   </script>
 
</head>
<body>
 
   <form runat=server>

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


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

   <script language="JSCRIPT" runat="server">
 
      function LinkButton_Click(sender : Object, e : EventArgs){
         Label1.Text = "You clicked the link button"
      }
 
   </script>
 
</head>
<body>
 
   <form runat=server>

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

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

LinkButton Class | LinkButton Members | System.Web.UI.WebControls Namespace | OnClick | CommandEventHandler

Show: