Redigera

Dela via


Image.ImageUrl Property

Definition

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 Mobile Apps & Sites with ASP.NET.

public:
 property System::String ^ ImageUrl { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string ImageUrl { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ImageUrl : string with get, set
Public Property ImageUrl As String

Property Value

The URL of the image source for the Image

Attributes

Examples

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.

Note

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.

Remarks

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

Applies to

See also