Images
Images are an important aspect of most websites. ASP.NET provides several ASP.NET server controls for displaying images. Two of them, the Image and the ImageMap controls, are covered in this section. The AdRotator control, which also displays images, will be covered in the next chapter.
Image Control
The Image control has limited functionality: it is used for displaying an image on a web page or, alternatively, displaying some text if the image is unavailable. It raises no events for user interaction, other than those inherited from Control, such as Init and Load. However, which image it displays and where it is aligned on the page can be set in code, so it is a legitimate alternative to using a static HTML <img> element.
Tip
If you need an image to have the same functionality as a button (i.e., to capture mouse clicks), you should use either the ImageButton control, or a HyperLink control with its ImageUrl property set.
In addition to the properties inherited from the WebControl class, the Image control has the read/write properties shown in Table 4-7.
Table 4-7. Properties of the Image control
Name | Type | Description |
|---|---|---|
| String | The text displayed in the control if the image is unavailable. In browsers that support the ToolTips feature this text is also displayed as a tool tip. |
|
| Alignment options relative to the text of the web page. See Table 4-8. |
| String | The URL pointing to the location of an image to display. |
The ImageUrl property can be either relative ...