AdRotator.NavigateUrlField Propriété

Définition

Obtient ou définit un champ de données personnalisé à utiliser à la place de l'attribut NavigateUrl d'une publication.

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

Valeur de propriété

Nom qui identifie le champ contenant l'URL de la page à atteindre lors d'un clic sur le contrôle AdRotator. La valeur par défaut est "NavigateUrl."

Exemples

L’exemple de code suivant illustre l’utilisation de la NavigateUrlField propriété pour spécifier un champ de données personnalisé. Les NavigateUrlFieldpropriétés , ImageUrlFieldet AlternateTextField sont utilisées pour sélectionner dynamiquement un champ personnalisé à utiliser à la NavigateUrlplace des attributs , ImageUrlet AlternateText . Cet exemple utilise un filtre d’appareil pour indiquer que les champs personnalisés doivent être utilisés pour les appareils compatibles avec le protocole WAP (Wireless Application Protocol).

<%@ 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>

Voici les exemples de données XML de l’exemple précédent.

<Advertisements>  
  <Ad>  
    <ImageUrl>~/Images/ad1.gif</ImageUrl>  
    <NavigateUrl>https://docs.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://docs.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>  

Remarques

La NavigateUrlField propriété permet de sélectionner un champ de données personnalisé utilisé à la place de l’attribut NavigateUrl d’une publicité. Comme NavigateUrl, ce champ personnalisé est défini dans le fichier XML qui contient des informations de publicité.

S’applique à

Voir aussi