asp.net.ph

Skip Navigation Links

Creating Graphical Button Controls

Controls You Can Use on Web Forms   ASP.NET Standard Controls   Button Controls


An ImageButton control allows you to present a graphic as a clickable control.

To create a graphical button

  1. Declare an <asp:ImageButton> element on the page.
  2. Set the button’s ImageUrl property to point to an image file ( .gif, .jpg, .png ).
  3. Assign the handler that will receive control when the Click event of the button occurs ( i.e., when a user clicks the control ).
<asp:ImageButton runat="server" 
   ImageUrl="myPic.jpg" 
   onClick="doSomething" />

The following sample illustrates using the ImageButton control.

Using Dynamic HTML Events with the ImageButton Control
Run Sample | View Source

The ImageUrl property can also be bound to a data source to display graphics based on database information, as when an ImageButton control is used within templated controls such as a DataGrid, DataList, GridView, FormView or Repeater.

The below example demonstrates how to assign a value to the ImageUrl property based on database information.

Dynamically Generated ImageButtons
Run Sample | View Source
See Also

Determining Coordinates In an ImageButton Control   ImageButton Control Syntax



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note