System.Web.UI.WebControls.ImageButton Class

A control that displays an image and responds to mouse clicks on the image.

See Also: ImageButton Members


[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.PreviewControlDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public class ImageButton : Image, System.Web.UI.IPostBackDataHandler, System.Web.UI.IPostBackEventHandler, IButtonControl


In this topic:


Use the System.Web.UI.WebControls.ImageButton control to display an image that responds to mouse clicks.

Both the ImageButton.Click and ImageButton.Command events are raised when the System.Web.UI.WebControls.ImageButton control is clicked.

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.

Determining Where the User Clicked

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.

ImageButton Controls and Validation

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.

Declarative Syntax


    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,