ASP.NET Syntax ASP.NET Syntax for Web Controls
Displays a Web-compatible image on the Web Forms page.
Declarative Syntax
<asp:Image
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
CssClass = "string"
DescriptionUrl = "uri"
Enabled = "True | False"
EnableTheming = "True | False"
EnableViewState = "True | False"
ForeColor = "color name | #dddddd"
GenerateEmptyAlternateText = "True | False"
Height = size
ID = "string"
ImageAlign = "NotSet | Left | Right | Baseline | Top | Middle | Bottom |
AbsBottom | AbsMiddle | TextTop"
ImageUrl = "uri"
OnDataBinding = "DataBinding event handler"
OnDisposed = "Disposed event handler"
OnInit = "Init event handler"
OnLoad = "Load event handler"
OnPreRender = "PreRender event handler"
OnUnload = "Unload event handler"
runat = "server"
SkinID = "string"
Style = "string"
TabIndex = integer
ToolTip = "string"
Visible = "True | False"
Width = size
/>
For information on the individual members of this class, see Image in the class library.
Property |
Description |
Base properties |
The properties inherited from the base WebControl class. |
AlternateText |
Text to display if the image referenced by ImageUrl is not available. In some browsers, the alternate text is displayed as a ToolTip when the user holds the mouse pointer over the image. |
ImageAlign |
The alignment of the image with surrounding text. The default is NotSet.
When programming, you set this property using the ImageAlign enumeration. |
ImageUrl |
The URL of the image to display. |
Use the Image control to display an image on a Web Forms page. Setting the ImageUrl property specifies the path to the displayed image. You can specify the text to display in place of the image when the image is not available by setting the AlternateText property. The alignment of the image in relation to other elements on the Web Forms page is specified by setting ImageAlign property.
NOTE: This control only displays an image. If you need to capture mouse clicks on the image, use the ImageButton control.
The below code snippet demonstrates how to use the Image control to display an image on a Web Forms page.
<asp:image id="imgEarth" runat="server"
imageurl = "/asp.net.ph/shared/images/earth.gif"
alternatetext = "Earth" />
Image Class Image Web Server Control