What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10691 |  Welcome, Guest!   Register  Login
Home > Tutorials > ASP.NET Tutorials > Link Button

Silverlight Tutorials | Report a Bug in the Tutorial
Found interesting? Add this to:


asp:LinkButton control
LinkButton control is a control just like a Button control along with the flexibility to make it look like 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 LinkButton 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 pages)

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 a button is clicked.
PostBackUrl Indicates the URL on which the Form will be posted back.
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 a Button.
OnClick Attach a server side method that will fire when button will be clicked. LinkButton: Activate Server Side Event
OnClientClick Attach a client side (javascript) method that will fire when button will be clicked. LinkButton: Activate Client Side Method
DEMO : Button Show Source Code
  LinkButton: Fire Server Side Event Ex. Example of Label Control
                        // With OnClick event
                        <asp:LinkButton ID="LinkButton1" runat="Server" Text="LinkButton: Activate Server Side Event" OnClick="ActivateServerSideEvent" />
                        
                        // With OnClientClick event and CommandName
                        <asp:LinkButton ID="LinkButton2" runat="Server" Text="LinkButton: Activate Client Side Method" OnClientClick="GiveAlertToUser()" UseSubmitBehavior="False" CommandName="ClientSideButton" />
                        
                        // With OnClick & ValidationGroup
                        <asp:LinkButton ID="LinkButton1" runat="Server" OnClick="FireServerSideEvent" Text="LinkButton: Fire Server Side Event" ValidationGroup="demo" />
                    
Here note that when you click "LinkButton: Fire Server Side Event" button, the form will be posted only when you have entered something into the TextBox, while other buttons are posted back without validatation. Here only textbox and "LinkButton: Fire Server Side Event" button have same ValidateionGroup called "demo", so this button is validating only textbox.





About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 3:03:17 PM