Image

The Image control allows you to display images on an ASP.NET web page and manage these images in your own code.

To add an Image control to a page

  1. Drag the Image control from the Toolbox panel to your page.

  2. In the Tag Properties panel, set the control's ImageUrl property to the URL of a .gif, .jpg, or other web graphic file.

  3. Optionally, set the following Image control properties.

Common Image control properties

Property Description

Height and Width

Reserve space for the graphic on the page. When the page is rendered, the image will be sized to fit the space you reserve.

ImageAlign

Aligns the image with respect to surrounding text, using values such as Top, Bottom, Left, Middle, and Right. In code, image alignment is set by using the ImageAlign enumeration.

AlternateText

Displays text in place of the graphic if the graphic can't be loaded. In some browsers, this text is also displayed as a ToolTip.

For a full description of all Image control properties, see Image Properties Cc295355.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

Note

The URL that is associated with an Image control points to an external resource. If you point to a resource that you do not own, be sure it is safe for your users to work with.

You can specify the graphics file for an Image control at design time or at run time programmatically. You can also bind the control's ImageUrl property to a data source to display graphics based on database information.

Unlike most other ASP.NET controls, the Image control does not support any events. For example, the Image control does not respond to mouse clicks. Instead, you can create an interactive image by using the ImageMap or the ImageButton ASP.NET controls.

For more information about working with the Image control, see Image Web Server Control Overview Cc295355.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

See also

Concepts

ImageMap
ImageButton

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.