Image Class

Provides control capability to specify an image to display.

public class System.Web.UI.MobileControls.Image : 
   System.Web.UI.MobileControls.MobileControl,
   System.Web.UI.IPostBackEventHandler

Remarks

The Image class provides a means of specifying multiple image files to be chosen based on device characteristics. It does not provide any services for translating images from one set of characteristics to another, such as converting color images to monochrome. At run time, you can specify multiple image files for the Image control to choose from, based on device characteristics. Or, you can declaratively specify the images for the control.

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 control.

Example

The following example presents an image to be displayed with its properties set upon Page_Load. The alternate text will appear in case the browser cannot display the image, or when an image is not found.

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

<script language="vb" runat="server">

Sub Page_Load()
   ' Programmatically add an image.
   Image1.ImageUrl = "MSImage.gif"

   ' Set the image properties programmatically.
   Image1.AlternateText = "No image available"
   Image1.Alignment = Alignment.Left
   Image1.NavigateURL = "http://www.microsoft.com"
End Sub

</script>

<mobile:Form id="Form1" runat="server" >
   <mobile:Image runat="server" id="Image1" />
</mobile:form>
[C#]
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" 
   Language="c#" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<script language="c#" runat="server">

void Page_Load()
{
   // Programmatically add an image.
   Image1.ImageUrl = "MSImage.gif";

   // Set the image properties programmatically.
   Image1.AlternateText = "No image available";
   Image1.Alignment = Alignment.Left;
   Image1.NavigateURL = "http://www.microsoft.com";
}

</script>

<mobile:Form id="Form1" runat="server" >
   <mobile:Image runat="server" id="Image1" />
</mobile:form>

Requirements

Namespace: System.Web.UI.MobileControls

Assembly: System.Web.Mobile

See Also

Image Control