Images

There are two ASP controls for displaying images: the Image control and the AdRotator control.

Image Control

The Image control has very limited functionality -- it is used for displaying an image on a web page or, alternatively, displaying some text if the image is not available. If you need to have button functionality (i.e., to capture mouse clicks), then you should use the ImageButton control, described earlier in this chapter.

In addition to the properties inherited from WebControl, the Image control has the properties shown in Table 5-16.

Table 5-16. Properties of the Image control

Name

Type

Get

Set

Values

Description

AlternateText

String

x

x

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 ToolTip.

ImageAlign

ImageAlign

x

x

See Table 5-17.

Alignment options relative to the text of the web page. See Table 5-17.

ImageURL

String

x

x

The URL pointing to the location of an image to display.

The ImageURL property can be either relative or absolute. A relative URL is the location relative to the location of the web page, without specifying a fully qualified path on the server. Using relative URLs makes it easier to move an entire site without modifying any of the code, as long as the image is in a subdirectory relative to the virtual root and the same directory structure is maintained. An absoluteURL provides a fully qualified path. If the site is moved, ...

Get Programming ASP .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.