Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Image Class
Collapse the table of content
Expand the table of content

Image Class

Displays an image on a Web page.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

No code example is currently available or this language may not be supported.
public class Image extends WebControl
public class Image extends WebControl
Not applicable.

Use the Image control to display any valid image supported by the requesting browser on the Web page. The path to the displayed image is specified by setting the ImageUrl property. You can specify the text to display in place of image when the image is not available by setting the AlternateText property. The alignment of the image in relation to other elements on the Web page is specified by setting ImageAlign property.


This control only displays an image. If you need to capture mouse clicks on the image, use the ImageButton control.


The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.

How to: Add Image Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add Image Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web DeveloperBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Creating an Accessible Web ApplicationBuilding ASP .NET Web Applications in Visual Studio
How to: Add Image Web Server Controls to a Web Forms Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio

The following example demonstrates how to create an Image control on a Web page.


The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

<%@ Page Language="JSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Image Example</title>
<script language="JSCRIPT" runat="server">

      function Button_Click(sender : Object, e : EventArgs){
            case 0:
               Image1.ImageAlign = ImageAlign.NotSet
            case 1:
               Image1.ImageAlign = ImageAlign.Left
            case 2:
               Image1.ImageAlign = ImageAlign.Right
            case 3:
               Image1.ImageAlign = ImageAlign.Baseline
            case 4:
               Image1.ImageAlign = ImageAlign.Top
            case 5:
               Image1.ImageAlign = ImageAlign.Middle
            case 6:
               Image1.ImageAlign = ImageAlign.Bottom
            case 7:
               Image1.ImageAlign = ImageAlign.AbsBottom
            case 8:
               Image1.ImageAlign = ImageAlign.AbsMiddle
            case 9:
               Image1.ImageAlign = ImageAlign.TextTop
               Image1.ImageAlign = ImageAlign.NotSet



   <form id="form1" runat="server">

      <h3>Image Example</h3>

      <div style="font-size:large">

         Text Text Text Text Text Text Text Text Text Text Text Text 
         Text Text Text Text Text Text Text Text Text Text Text Text 
         Text Text Text Text Text Text Text Text Text Text Text Text

      <asp:Image id="Image1" runat="server"
           AlternateText="Image text"

      <hr />
      Select Image Align: <br />

      <asp:DropDownList id="DropList1"



      <br /><br />

      <asp:Button id="Button1"
           Text="Apply Image Alignment"


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft