See Also: ImageButton Members
In this topic:
Use the System.Web.UI.WebControls.ImageButton control to display an image that responds to mouse clicks.
You can use the ImageButton.OnCommand(CommandEventArgs) event handler to make the System.Web.UI.WebControls.ImageButton control behave like a Command button. A command name can be associated with the control by using the ImageButton.CommandName property. This allows multiple System.Web.UI.WebControls.ImageButton controls to be placed on the same Web page. The value of the ImageButton.CommandName property can then be programmatically identified in the ImageButton.OnCommand(CommandEventArgs) event handler to determine the appropriate action to perform when each System.Web.UI.WebControls.ImageButton control is clicked. The ImageButton.CommandArgument property can also be used to pass additional information about the command, such as specifying ascending order.
Using the System.Web.UI.WebControls.ImageButton control is similar to using the ASP.NET System.Web.UI.WebControls.Button control. For more information, see Button Web Server Controls Overview. and the class overview for the System.Web.UI.WebControls.Button control.
By using the ImageButton.OnClick(System.Web.UI.ImageClickEventArgs) event handler, 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 that the origin (0, 0) is located at the upper left corner of the image.
By default, page validation is performed when an System.Web.UI.WebControls.ImageButton control is clicked. Page validation determines whether the input controls associated with a validation control on the page all pass the validation rules specified by the validation control. To prevent page validation from occurring, set the ImageButton.CausesValidation property to false.
For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.
<asp:ImageButton AccessKey="string" AlternateText="string" BackColor="color name|#dddddd" BorderColor="color name|#dddddd" BorderStyle="