ASP.NET HtmlInputImage Control

Definition and Usage

The HtmlInputImage control is used to control the <input type="image"> element.

In HTML, this element is used to create buttons using images, which can replace conventional buttons.

Properties

Properties Description
Align The alignment of the image.
Alt Alternative text for the image to be displayed.
Attributes Returns all attribute names and value pairs of the element.
Border The width of the border around the element.
Disabled Boolean value indicating whether the control is disabled. The default is false.
id The unique id of the control.
Name The name of the element.
OnServerClick The name of the function executed when the image is clicked.
runat Must be set to "server" as it specifies that the control is a server control.
Src The source of the image.
Style Sets or returns the CSS properties applied to the control.
TagName Returns the tag name of the element.
Type The type of the element.
Value The value of the element.
Visible Boolean value indicating whether the control is visible.

Example

HTMLInputImage
In this example, we declare two HtmlInputImage controls and one HtmlGeneric control in the .aspx file. If the user clicks the first image, the button1 subroutine will be executed. This subroutine will send the message "You clicked the smiley button!" to the p element. If the user clicks the second image, the button2 subroutine will be executed. This subroutine will send the message "You clicked the angry button!" to the p element.