Image Class

Displays an image on a mobile Web page.

Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile (in

public class Image : MobileControl, IPostBackEventHandler
public class Image extends MobileControl implements IPostBackEventHandler
public class Image extends MobileControl implements IPostBackEventHandler

The Image class provides a way to choose an image file based on device characteristics. For certain devices, you can specify built-in images by using a symbol : prefix as part of the URL in the ImageUrl property. For more information, see the Device-Specific section of the Image.

The following code sample code shows how to use a <DeviceSpecific> control within an Image control to specify different images for different devices. If you have available a file named Sunshine.gif, it will appear in Internet Explorer. If you view the page on a WML device such as an OpenWave phone or a CHTML device, it will appear as a sun icon. The page also displays the name of the browser and the resolved name of the image.


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, see ASP.NET Web Page Code Model.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
        string spec1 = "Device: {0}";
        string spec2 = "Image source: {0}";

        if (!IsPostBack)
            Label1.Text = String.Format(spec1,  Device.Browser);
            Label2.Text = string.Format(spec2, Image1.ImageUrl);

<html xmlns="" >
    <mobile:form id="form1" runat="server">
        <mobile:Image ID="Image1" Runat="server" 
            <DeviceSpecific ID="imgDevSec" Runat="server">
                <Choice Filter="isWML11" 
                        ImageUrl="symbol:44" />
                <Choice Filter="isCHTML10" 
                        ImageUrl="symbol:63726" />
                <Choice ImageUrl="sunshine.gif" />
        <mobile:Label ID="Label1" Runat="server" />
        <mobile:Label ID="Label2" Runat="server" />

The following is the <deviceFilters> section of the Web.config file.

  <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" />
  <filter name="isCHTML10" compare="PreferredRenderingType" argument="chtml10" />

  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.

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 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions