Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET HtmlImage Control

ASP.NET HtmlImage Control


HTML Server Controls HTML Server Controls


Definition and Usage

The HtmlImage control is used to control the element. In HTML, element is used to display an image.


property

property Description
Align How to align the image relative to surrounding elements. Valid values are:
  • top
  • middle
  • bottom
  • left
  • right
  • | | Alt | A short description of the image. | | Attributes | Returns all attribute name and value pairs of the element. | | Border | The width of the border around the image. | | Disabled | Boolean, indicates whether the control is disabled. The default is false. | | Height | The height of the image. | | id | The unique id of the control. | | runat | Specifies that this control is a server control. Must be set to "server". | | Src | The URL of the image to display. | | Style | Sets or returns the CSS properties applied to the control. | | TagName | Returns the tag name of the element. | | Visible | Boolean, indicates whether the control is visible. | | Width | The width of the image. |

    Example

    HTMLImage
    In this example, we declare an HtmlImage control in the .aspx file (remember to nest the control inside the HtmlForm control). Then we modify the src, alt, and border attributes of this HtmlImage control in an event handler (a subroutine that executes code for a given event). The Page_Load event is one of the many events that ASP.NET understands.

    HTMLImage 2
    In this example, we declare an HtmlImage control and an HTMLSelect control in the .aspx file (remember to nest the controls inside the HtmlForm control). Then we modify the src attribute of the HtmlImage control based on the user's selection. The value selected in the HtmlSelect control determines which image is displayed.


    HTML Server Controls HTML Server Controls