Bagikan melalui


AdRotator.ImageUrlField Properti

Definisi

Mendapatkan atau mengatur bidang data kustom untuk digunakan sebagai pengganti ImageUrl atribut untuk iklan.

public:
 property System::String ^ ImageUrlField { System::String ^ get(); void set(System::String ^ value); };
public string ImageUrlField { get; set; }
member this.ImageUrlField : string with get, set
Public Property ImageUrlField As String

Nilai Properti

Nama yang mengidentifikasi bidang tempat URL untuk gambar yang ditampilkan untuk iklan disimpan. Nilai defaultnya adalah "ImageUrl."

Contoh

Contoh kode berikut menunjukkan penggunaan ImageUrlField properti untuk menentukan bidang data kustom. Properti NavigateUrlField, ImageUrlField, dan AlternateTextField digunakan untuk memilih bidang kustom secara dinamis untuk digunakan sebagai pengganti NavigateUrlatribut , ImageUrl, dan AlternateText . Contoh ini menggunakan filter perangkat untuk menunjukkan bahwa bidang kustom harus digunakan untuk perangkat yang diaktifkan Wireless Application Protocol (WAP).

<%@ 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>
<%@ page language="VB" %>

<!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>

Berikut ini adalah contoh data XML untuk contoh sebelumnya.

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

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

Keterangan

Properti ImageUrlField digunakan untuk memilih bidang data kustom yang digunakan sebagai pengganti ImageUrl atribut untuk iklan. Seperti ImageUrl, bidang kustom ini ditentukan dalam file XML yang berisi informasi iklan.

Berlaku untuk

Lihat juga