LinkButton Control in ASP.NET

The LinkButton is a valuable element that presents a button-like control with a hyperlink appearance on a Web page. By default, the LinkButton control functions as a Submit button, allowing the user to submit form data or trigger a specific action. Additionally, the CommandArgument property can be utilized in conjunction with a Command button, offering the capability to include supplementary details about the intended command, such as specifying ascending order for a specific operation. This feature enhances the flexibility and versatility of the LinkButton control, enabling developers to provide more context and customization options to users.

linkbutton-control

Default.aspx

<html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">VB.NET</asp:LinkButton><br /> <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">C#</asp:LinkButton><br /> <asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label> </div> </form> </body> </html>
Full Source | C#
using System; public partial class _Default : System.Web.UI.Page { protected void LinkButton1_Click(object sender, EventArgs e) { Label1.Text = "VB.NETm is clicked "; } protected void LinkButton2_Click(object sender, EventArgs e) { Label1.Text = "C# is clicked "; } }
Full Source | VB.NET
Partial Class _Default Inherits System.Web.UI.Page Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Label1.Text = "VB.NET is clickecd " End Sub Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click Label1.Text = "C# is clickecd " End Sub End Class