System.Web 1.0.5000.0 2.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Web.UI.WebControls.Image System.Web.UI.IPostBackDataHandler System.Web.UI.IPostBackEventHandler System.Web.UI.WebControls.IButtonControl System.Web.UI.SupportsEventValidation System.ComponentModel.Designer("System.Web.UI.Design.WebControls.PreviewControlDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner") System.ComponentModel.DefaultEvent("Click") In this topic: Introduction Determining Where the User Clicked ImageButton Controls and Validation Accessibility Declarative Syntax

Introduction

Use the control to display an image that responds to mouse clicks. Both the and events are raised when the control is clicked. You can use the event handler to make the control behave like a Command button. A command name can be associated with the control by using the property. This allows multiple controls to be placed on the same Web page. The value of the property can then be programmatically identified in the event handler to determine the appropriate action to perform when each control is clicked. The property can also be used to pass additional information about the command, such as specifying ascending order. Using the control is similar to using the ASP.NET control. For more information, see
Button Web Server Controls Overview. and the class overview for the control.

Determining Where the User Clicked

By using the 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 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 property to false.

Accessibility

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

<asp:ImageButton     AccessKey="string"     AlternateText="string"     BackColor="color name|#dddddd"     BorderColor="color name|#dddddd"     BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset"     BorderWidth="size"     CausesValidation="True|False"     CommandArgument="string"     CommandName="string"     CssClass="string"     DescriptionUrl="uri"     Enabled="True|False"     EnableTheming="True|False"     EnableViewState="True|False"     ForeColor="color name|#dddddd"     Height="size"     ID="string"     ImageAlign="NotSet|Left|Right|Baseline|Top|Middle|Bottom| AbsBottom|AbsMiddle|TextTop"     ImageUrl="uri"     OnClick="Click event handler"     OnClientClick="string"     OnCommand="Command event handler"     OnDataBinding="DataBinding event handler"     OnDisposed="Disposed event handler"     OnInit="Init event handler"     OnLoad="Load event handler"     OnPreRender="PreRender event handler"     OnUnload="Unload event handler"     PostBackUrl="uri"     runat="server"     SkinID="string"     Style="string"     TabIndex="integer"     ToolTip="string"     ValidationGroup="string"     Visible="True|False"     Width="size" />
A control that displays an image and responds to mouse clicks on the image.
Constructor Use this constructor to create and initialize a new instance of the class. Initializes a new instance of the class. 1.0.5000.0 2.0.0.0 Method System.Void The method is used primarily by control developers when deriving a custom class from the control. Adds the attributes of an to the output stream for rendering on the client. The output stream to render on the client. 1.0.5000.0 2.0.0.0 Property System.Boolean To be added: an object of type 'bool' By default, page validation is performed when an 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. You can specify or determine whether validation is performed on both the client and the server when an control is clicked by using the property. To prevent validation from being performed, set the property to false. This property is commonly set to false for a Reset or Clear button to prevent validation from being performed when the button is clicked. When the value of the property is set to true, you can also use the property to specify the name of the validation group for which the control causes validation. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets a value indicating whether validation is performed when the control is clicked. 1.0.5000.0 2.0.0.0 System.Web.UI.Themeable(false) System.ComponentModel.DefaultValue(true) Event System.Web.UI.ImageClickEventHandler The event is raised when the control is clicked. This event causes the page to be posted back to the server. For more information about handling events, see How to: Consume Events in a Web Forms Application. Occurs when the is clicked. 1.0.5000.0 2.0.0.0 Event System.Web.UI.WebControls.CommandEventHandler The event is raised when an control is clicked. The event is raised through the control hierarchy in the form of the BubbleEvent. This event causes the page to post back to the server. For more information about handling events, see How to: Consume Events in a Web Forms Application. Occurs when the is clicked. 1.0.5000.0 2.0.0.0 Property System.String To be added: an object of type 'string' Sometimes, multiple controls are related and share the same value for the property, such as Sort. Use this property to supplement the property with additional information about the command to perform, such as Ascending. The values of the and properties are typically used in the event handler to determine the action to perform when the control is clicked. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets an optional argument that provides additional information about the property. 1.0.5000.0 2.0.0.0 System.Web.UI.Themeable(false) System.ComponentModel.DefaultValue("") System.ComponentModel.Bindable(true) Property System.String To be added: an object of type 'string' Use this property to specify the command to perform when the control is clicked, such as Sort, Cancel, or Edit. This allows multiple controls to be placed on the same Web page. The value in this property can then be programmatically identified in the event handler to determine the appropriate action to perform when each control is clicked. Supplemental information about the command, such as specifying ascending sort order, can be included by using the property. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the command name associated with the control. 1.0.5000.0 2.0.0.0 System.Web.UI.Themeable(false) System.ComponentModel.DefaultValue("") Property 1.0.5000.0 2.0.0.0 System.ComponentModel.Bindable(true) System.ComponentModel.DefaultValue(true) System.ComponentModel.Browsable(true) System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always) System.Boolean To be added. Use the property to specify whether an can be clicked to perform a post back to the server. If you set this property to false, the control renders on the page, but does not raise a post back event when clicked. Gets or sets a value indicating whether the can be clicked to perform a post back to the server. Property 2.0.0.0 System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden) System.Web.UI.Themeable(false) System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never) System.ComponentModel.Browsable(false) System.Boolean To be added. By default, the control renders the property using an alt attribute. When the property is not set, the control does not include the alt attribute to specify the alternate-text in the control rendering. The XHTML document type definition requires the alt attribute on image controls. However, accessibility best practices recommend that image controls that do not convey information relevant to the context of the Web page should not specify an alt attribute. You can meet both XHTML and accessibility requirements by setting the property to true. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets a value indicating whether the control generates an alternate-text attribute for an empty string value. Method 2.0.0.0 System.Web.UI.PostBackOptions The method creates a object that represents the control's postback behavior. The object is then typically passed to the method, which is used to obtain a reference to a client-side script function that, when invoked, causes the server to postback to the page. This method is used primarily by control developers when extending the class. Creates a object that represents the control's postback behavior. A that represents the control's postback behavior. Method 2.0.0.0 System.Boolean The member is used primarily by control developers when deriving a custom class from the control. The checks to see if the x and y values were posted, which indicates that the image was clicked by the user. The then registers with the page that it wants to raise an event during the event-processing phase. Processes posted data for the control. Returns false for all cases. The key value used to index an entry in the collection. A that contains post information. Method System.Void The event is raised when the control is clicked. By using the event handler, you can programmatically determine the coordinates where the image is clicked. You can then code a response, based on the values of these coordinates. Note that the origin (0, 0) is located at the upper left corner of the image. Raising an event invokes the event handler through a delegate. For more information, see How to: Consume Events in a Web Forms Application. The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. Raises the event and allows you to handle the event directly. A that contains the event data. 1.0.5000.0 2.0.0.0 Property 2.0.0.0 System.Web.UI.Themeable(false) System.ComponentModel.DefaultValue("") System.String To be added. Use the property to specify additional client-side script that executes when an control's event is raised. The script that you specify for this property is rendered in the control's OnClick attribute in addition to the control's predefined client-side script. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the client-side script that executes when an control's event is raised. Method System.Void The event is raised when the control is clicked. The event handler is used to make the control behave like a Command button. A command name can be associated with the control by using the property. This allows multiple controls to be placed on the Web page. The value in this property can then be programmatically identified in the event handler to determine the appropriate action to perform when each control is clicked. The property can also be used to pass additional information about the command, such as specifying ascending order. The event is raised through the control hierarchy in the form of the BubbleEvent. Raising an event invokes the event handler through a delegate. For more information, see How to: Consume Events in a Web Forms Application. The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. Raises the event and allows you to handle the event directly. A that contains the event data. 1.0.5000.0 2.0.0.0 Method System.Void The method is used primarily by control developers when deriving a custom class from the control. Determines whether the image has been clicked prior to rendering on the client. An object that contains the event data. 1.0.5000.0 2.0.0.0 Property 2.0.0.0 System.ComponentModel.Editor("System.Web.UI.Design.UrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") System.ComponentModel.DefaultValue("") System.Web.UI.UrlProperty("*.aspx") System.Web.UI.Themeable(false) System.String To be added. The property allows you to perform a cross-page post using the control. Set the property to the URL of the Web page to post to when the control is clicked. For example, specifying Page2.aspx causes the page that contains the control to post to Page2.aspx. If you do not specify a value for the property, the page posts back to itself. When performing a cross-page postback with controls with server-side validation, you should check that the page's property is true before processing the postback. In the case of a cross-page postback, the page to check is the PreviousPage. The following Visual Basic code shows how this is done: Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.PreviousPage.IsValid Then ' Handle the post back Else Response.Write("Invalid") End If End Sub For more information on cross-page posting techniques, see Cross-Page Posting in an ASP.NET Web Page. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the URL of the page to post to from the current page when the control is clicked. Method 2.0.0.0 System.Void The member is used primarily by control developers when deriving a custom class from the control. This method is used internally by the control, when it is clicked, to raise a event and, if defined, a event. Raises events for the control when it posts back to the server. The argument for the event. Method 2.0.0.0 System.Void The member is used primarily by control developers when deriving a custom class from the control. This method can be overridden in a derived class to raise change events for the control when it posts back to the server. Notifies the ASP.NET application that the state of the control has changed. Method 1.0.5000.0 2.0.0.0 System.Boolean The method is an explicit interface member implementation. It can be used only when the instance is cast to an interface. For a description of this member, see . true if the server control's state changes as a result of the postback; otherwise, false. The key identifier for the control, used to index the . A collection that contains value information indexed by control identifiers. Method 1.0.5000.0 2.0.0.0 System.Void The method is an explicit interface member implementation. It can be used only when the instance is cast to an interface. For a description of this member, see . Method 1.0.5000.0 2.0.0.0 System.Void The method is an explicit interface member implementation. It can be used only when the instance is cast to an interface. For a description of this member, see . The argument for the event Property 2.0.0.0 System.String To be added. The member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. For a description of this member, see . Property System.Web.UI.HtmlTextWriterTag a The property is used primarily by control developers when deriving a custom class from the control. Use the property to determine the value associated with an control. This property overrides the base implementation to always return HtmlTextWriterTag.Input. Gets the value that corresponds to the control. 1.0.5000.0 2.0.0.0 System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden) System.ComponentModel.Browsable(false) Property 2.0.0.0 System.String To be added. The property is not intended to be called directly from your code. Gets or sets the value of the control's property. Property 2.0.0.0 System.ComponentModel.DefaultValue("") System.Web.UI.Themeable(false) System.String To be added. Validation groups allow you to assign validation controls on a page to a specific category. Each validation group can be validated independently of other validation groups on the page. Use the property to specify the name of the validation group for which the control causes validation when it posts back to the server. This property has an effect only when the value of the property is set to true. When you specify a value for the property, only the validation controls that are part of the specified group are validated when the control posts back to the server. If you do not specify a value for this property and the property is set to true, all validation controls on the page that are not assigned to a validation group are validated when the control posts back to the server. This property cannot be set by themes or style sheet themes. For more information, see and ASP.NET Themes Overview. Gets or sets the group of controls for which the control causes validation when it posts back to the server.