Export (0) Print
Expand All

AdRotator.ImageUrlField Property

Gets or sets a custom data field to use in place of the ImageUrl attribute for an advertisement.

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

public string ImageUrlField { get; set; }

Property Value

Type: System.String
The name that identifies the field where the URL for the image displayed for an advertisement is stored. The default value is "ImageUrl."

The ImageUrlField property is used for selecting a custom data field used in place of the ImageUrl attribute for an advertisement. Like ImageUrl, this custom field is defined in the XML file that contains advertisement information.

The following code example demonstrates using the ImageUrlField property to specify a custom data field. The NavigateUrlField, ImageUrlField, and AlternateTextField properties are used to dynamically select a custom field to use in place of the NavigateUrl, ImageUrl, and AlternateText attributes. This example uses a device filter to indicate that custom fields should be used for Wireless Application Protocol (WAP)-enabled devices.

<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <p>This example demonstrates using the AdRotator control.</p>
    <p>
      <asp:AdRotator ID="AdRotator1" Runat="server" 
        DataSourceID="Ads"
        Winwap:NavigateUrlField="WMLNavigateUrl"
        Winwap:ImageUrlField="WmlImageUrl"
        Winwap:AlternateTextField="WmlAlternateText"
      />
      <asp:XmlDataSource ID="Ads" 
        Runat="server" 
        DataFile="~/App_Data/AdvertisementList.xml">
      </asp:XmlDataSource>
    </p>
  </div>
  </form>
</body>
</html>

The following is the sample XML data for the previous example.

<Advertisements>
  <Ad>
    <ImageUrl>~/Images/ad1.gif</ImageUrl>
    <NavigateUrl>http://msdn.microsoft.com/vbasic/</NavigateUrl>
    <AlternateText>Visual Basic Developer Site</AlternateText>
    <Width>140</Width>
    <Height>100</Height>
      <!-- The following custom elements will be used by WAP-enabled
        devices. -->
     <WmlImageUrl>~/Images/mobileAd1.jpg</WmlImageUrl>
    <WmlNavigateUrl>http://msdn.microsoft.com/mobile/</WmlNavigateUrl>
    <WmlAlternateText>Windows Mobile Developer Site</WmlAlternateText>

  </Ad>
  <Ad>
    <ImageUrl>~/Images/ad2.gif</ImageUrl>
    <NavigateUrl>http://msdn.microsoft.com</NavigateUrl>
    <AlternateText>MSDN</AlternateText>
    <Width>150</Width>
    <Height>150</Height>
    <!-- The following custom elements will be used by WAP-enabled
      devices. -->
    <WmlImageUrl>~/Images/mobileAd2.jpg</WmlImageUrl>
    <WmlNavigateUrl>http://msdn.microsoft.com/mobility/</WmlNavigateUrl>
    <WmlAlternateText>Windows Mobile Developer Site</WmlAlternateText>
  </Ad>
</Advertisements>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft