Export (0) Print
Expand All

Image.ImageUrl Property

Gets or sets the URL of the image source for the Image control. This API is obsolete. For information about how to develop ASP.NET mobile applications, see the www.asp.net/mobile Web site.

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

'Declaration
<BindableAttribute(True)> _
Public Property ImageUrl As String
<asp:Image ImageUrl="String" />

Property Value

Type: System.String
The URL of the image source for the Image

Because various devices provide a set of built-in pictures, such as images for a heart, sunshine, a book, a right arrow, and so on, by using a <DeviceSpecific> control within the Image control, you can provide a wide variety of graphics that can be integrated into the devices themselves, as well as standard Web graphics.

For example, you can specify symbol:63726 as the ImageUrl property value for all devices that require WML markup, and Sunshine.gif as the ImageUrl property value for HTML devices.

The exact resolution of the ImageUrl value is provided by an image adapter (such as ChtmlImageAdapter, WmlImageAdapter, or XhtmlImageAdapter).

The following code example shows how to use a <DeviceSpecific> control within an Image control to specify different images for different devices. If a file named Sunshine.gif is available, 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.

NoteNote

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 Forms Page Code Model.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    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);
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Image ID="Image1" Runat="server" 
            AlternateText="Sunshine">

            <DeviceSpecific ID="imgDevSec" Runat="server">
                <Choice Filter="isWML11" 
                        ImageUrl="symbol:44" />
                <Choice Filter="isCHTML10" 
                        ImageUrl="symbol:63726" />
                <Choice ImageUrl="sunshine.gif" />
            </DeviceSpecific>

        </mobile:Image>
        <mobile:Label ID="Label1" Runat="server" />
        <mobile:Label ID="Label2" Runat="server" />
    </mobile:form>
</body>
</html>

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

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft