Where & When to use asp:LinkButton Control

LinkButton control is a control just like a Button control along with the flexibility to make it look like a Hyperlink.  It implements an anchor <a/> tag that uses only ASP.NET postback mechanism to post the data on the server. Despite being a hyperlink, you can’t specify the target URL. There is no UserSubmitBehavior property like Button control with this control.

Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <a/> tag. You can set its Text property either by setting Text properties in the .aspx page or from server side page. (other properties can also be set from both sides)

Following are some important properties that are very useful.

CausesValidation Value can be set as true/false. This indicates whether validation will be performed when this button will be clicked.
PostBackUrl Indicates the URL on which the Form will be posted back if this button will be clicked.
ValidationGroup Gets or Sets the name of the validation group that the button belongs to. This is used to validate only a set of Form controls with this Button.
OnClick Attach a server side method that will fire when this button will be clicked.
OnClientClick Attach a client side (javascript) method that will fire when this button will be clicked.

Note that this button will not work if JavaScript is disabled in the browser as ASP.NET write its own function to post data to the server when this button is clicked.

Usually, this control is used to give a uniform look and feel through out the page/site if you are using hyperlink to navigate through the site. Also if you have less space and want to show a control that can actually fire server side event, placing Button control will not work as this take more space as well as its look and feel is completely different than LinkButton control.

Tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.