다음을 통해 공유


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