Showing posts with label LinkButton. Show all posts
Showing posts with label LinkButton. Show all posts

Thursday 27 April 2017

Different types of Button controls in Asp.Net

In this post, I will explain different types of button controls available in Asp.Net.

ASP.Net provides three types of button controls and these are used to post a page to the server. 
1.     Button
2.     LinkButton
3.     ImageButton

1.    Button
Button control displays a push-button control with text in a rectangular area. By default, a Button control is a Submit button. We can use Text property to change the text of Button. We can provide an event handler for the Click event to programmatically control the actions performed when the Submit button is clicked. 

Syntax of Button control -
<asp:Button ID="Button1" runat="server" Text="Button" />

2.   LinkButton
LinkButton displays a hyperlink-style button control. By default, a LinkButton control is a Submit button. We can use Text property to change the text of a LinkButton. We can provide a link to another page using PostbackUrl property. LinkButton can be used in the scenario where we need to add functionality with a hyperlink. 

Syntax of LinkButton control -
<asp:LinkButton runat="server" PostBackUrl="test.aspx"> LinkButton </asp:LinkButton>

3.   ImageButton
ImageButton displays a clickable image control. By default, ImageButton control is a submit button. We can use ImageUrl property to associate an image with ImageControl. ImageButton can be used in the scenario where we need to add functionality with an Image. 

Syntax of ImageButton control -
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Image.gif" />