System.Web.UI.WebControls Namespace
Renders an image that responds to mouse clicks.
Visibility |
Constructor |
Parameters |
public |
ImageButton |
( )
|
|
Use the ImageButton control to display an image that responds to mouse clicks. An ImageButton can be used either as a submit or command button that posts the page back to the server.
By default, an ImageButton control is a submit button, which simply posts the Web page back to the server. To programmatically control the action performed when the imagebutton is clicked, you define an event handler for the imagebutton's Click event.
Unlike the Button and LinkButton controls, though, you can programmatically determine the coordinates where the image is clicked. You can then code a response based on the values of the coordinates. Note the origin ( 0, 0 ) is located at the upper left corner of the image.
A command imagebutton, on the other hand, is an ImageButton control that can be used to invoke commands. This is basically done by associating the imagebutton with a CommandName ( ex. select, sort, edit, update, delete, etc. ). This allows you to create multiple ImageButton controls on a Web page and programmatically determine which imagebutton is clicked.
An optional CommandArgument property can be used with a command imagebutton to provide additional information about the command to perform ( ex. ascending ). Likewise, to programmatically control the actions performed when the command imagebutton is clicked, you define an event handler for the imagebutton's Command event.
For examples illustrating use of this control, see the individual member types of this class. For syntax information, see ImageButton in ASP.NET Syntax for Web Controls.
Button LinkButton Image