System.Web.UI.WebControls.LinkButton Class

Displays a hyperlink-style button control on a Web page.

See Also: LinkButton Members


[System.Web.UI.ToolboxData("<{0}:LinkButton runat="server">LinkButton</{0}:LinkButton>")]
[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.LinkButtonDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.Web.UI.DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class LinkButton : WebControl, System.Web.UI.IPostBackEventHandler, IButtonControl


In this topic:


Use the System.Web.UI.WebControls.LinkButton control to create a hyperlink-style button on the Web page. The System.Web.UI.WebControls.LinkButton control has the same appearance as a System.Web.UI.WebControls.HyperLink control, but has the same functionality as a System.Web.UI.WebControls.Button control. If you want to link to another Web page when the control is clicked, consider using the System.Web.UI.WebControls.HyperLink control.


The System.Web.UI.WebControls.LinkButton control renders JavaScript to the client browser. The client browser must have JavaScript enabled for this control to function properly. For more information on client script, see Client Script in ASP.NET Web Pages.

You can create either a Submit button or a Command button. A Submit button does not have a command name associated with it. The button simply posts the Web page back to the server. By default, a System.Web.UI.WebControls.LinkButton control is a Submit button. You can provide an event handler for the LinkButton.Click event to programmatically control the actions performed when the Submit button is clicked. On the other hand, a Command button has a command name associated with the button, such as Sort. Set the LinkButton.CommandName property to specify the command name. This allows you to create multiple System.Web.UI.WebControls.LinkButton controls on a Web page and programmatically determine which System.Web.UI.WebControls.LinkButton control is clicked. You can also use the LinkButton.CommandArgument property with a Command button to provide additional information about the command to perform, such as specifying ascending order. You can also provide an event handler for the LinkButton.Command event to programmatically control the action performed when the Command button is clicked.


This control can be used to display user input, which might include malicious client script. Text is not HTML encoded before it is displayed in the System.Web.UI.WebControls.LinkButton control. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see [<topic://cpconASPNETSyntaxForValidationControls>].

LinkButton Controls and Validation

By default, page validation is performed when a System.Web.UI.WebControls.LinkButton control is clicked. Page validation determines whether the input controls associated with a validation control on the page all pass the validation rules specified by the validation control. To prevent page validation from occurring, set the LinkButton.CausesValidation property to false.

Declarative Syntax


    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,