HtmlInputImage Class
Allows programmatic access to the HTML <input type= image> element on the server.
For a list of all members of this type, see HtmlInputImage Members.
System.Object
System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlInputControl
System.Web.UI.HtmlControls.HtmlInputImage
[Visual Basic] Public Class HtmlInputImage Inherits HtmlInputControl Implements IPostBackDataHandler, IPostBackEventHandler [C#] public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler, IPostBackEventHandler [C++] public __gc class HtmlInputImage : public HtmlInputControl, IPostBackDataHandler, IPostBackEventHandler [JScript] public class HtmlInputImage extends HtmlInputControl implements IPostBackDataHandler, IPostBackEventHandler
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
Use the HtmlInputImage control to create a button that displays an image. You can programmatically control the action associated with the HtmlInputImage control by providing an event handler for the ServerClick event.
The coordinates where the user clicks an HtmlInputImage control can be determined by using the ImageClickEventArgs.X and ImageClickEventArgs.Y properties of the System.Web.UI.ImageClickEventArgs object that is passed as a parameter to the user-defined event handler.
Note Unlike <button> elements, all browsers support the HTML <input type=image> element.
For a list of initial property values for an instance of HtmlInputImage, see the HtmlInputImage constructor.
Example
[Visual Basic, JScript] The following example demonstrates how to use the HtmlInputImage control to create a button that displays an image.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <script language="VB" runat=server> Sub SubmitBtn_Click(ByVal Source As Object, ByVal E as ImageClickEventArgs) Message.InnerHtml = "The Submit Button was clicked!" End Sub Sub ClearBtn_Click(ByVal Source As Object, ByVal E as ImageClickEventArgs) Message.InnerHtml = "The Clear Button was clicked!" End Sub </script> <body> <form method=post runat=server> <input type=image src="Submit.jpg" OnServerClick="SubmitBtn_Click" runat=server> <input type=image src="Clear.jpg" OnServerClick="ClearBtn_Click" runat=server> <h1> <span id="Message" runat=server></span> </h1> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <script language="JSCRIPT" runat=server> function SubmitBtn_Click(source : Object, e : ImageClickEventArgs){ Message.InnerHtml = "The Submit Button was clicked!" } function ClearBtn_Click(source : Object, e : ImageClickEventArgs){ Message.InnerHtml = "The Clear Button was clicked!" } </script> <body> <form method=post runat=server> <input type=image src="Submit.jpg" OnServerClick="SubmitBtn_Click" runat=server> <input type=image src="Clear.jpg" OnServerClick="ClearBtn_Click" runat=server> <h1> <span id="Message" runat=server></span> </h1> </form> </body> </html>
[C#, C++] No example is available for C# or C++. To view a Visual Basic or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI.HtmlControls
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web (in System.Web.dll)
See Also
HtmlInputImage Members | System.Web.UI.HtmlControls Namespace | HtmlInputControl | ServerClick | System.Web.UI.ImageClickEventArgs