Image Web Server Control
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.NET Framework General Reference
Image Web Server Control

Displays a Web-compatible image on the Web Forms page.

<asp:Image id="Image1" runat="server"
     ImageUrl="string"
     AlternateText="string"
     ImageAlign="NotSet|AbsBottom|AbsMiddle|BaseLine|
                Bottom|Left|Middle|Right|TextTop|Top"/>

Remarks

Use the Image control to display an image on the 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 ImageAlign property specifies the alignment of the image in relation to other elements on the Web Forms page.

Note   This control only displays an image. If you want the image to behave like a button or need to determine the coordinates where the mouse pointer is clicked on the image, use the ImageButton control.
Note   Because the <asp:Image> element has no content, you can close the tag with /> instead of using a separate closing tag.

For detailed information on the Image Web server control's properties and events, see the Image documentation.

Example

The following example demonstrates how to use the Image control to display an image on a Web Forms page.

<html>
<head>
</head>
<body>
   <form runat="server">
      <h3>Image Sample</h3>
      <asp:Image id="image1" runat="server"
           AlternateText="Image Description"
           ImageAlign="left"
           ImageUrl="pict.jpg"/>        
    </form>
</body>
</html>

See Also

Web Server Controls | Image Class

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View