Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Add Image Web Server Controls to a Web Forms Page

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

To add an Image Web server control to a Web Forms page

  1. From the Standard tab of the Toolbox, drag an Image control onto the page.

  2. In the Appearance category of the Properties window, set the control's ImageUrl property to the URL of a .gif, .jpg, or other Web graphic file.

    Security noteSecurity Note:

    The URL that is associated with a 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. For more information, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings.

    NoteNote:

    Click the button in the property box to display the Select Image dialog box, where you can select an image file.

  3. Optionally, set the following 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 the 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 cannot be loaded. In some browsers, this text is also displayed as a ToolTip.

Community Additions

ADD
Show:
© 2015 Microsoft