AdCreatedEventArgs Klasa

Definicja

Udostępnia dane dotyczące AdCreated zdarzenia kontrolki AdRotator . Klasa ta nie może być dziedziczona.

public ref class AdCreatedEventArgs sealed : EventArgs
public ref class AdCreatedEventArgs : EventArgs
public sealed class AdCreatedEventArgs : EventArgs
public class AdCreatedEventArgs : EventArgs
type AdCreatedEventArgs = class
    inherit EventArgs
Public NotInheritable Class AdCreatedEventArgs
Inherits EventArgs
Public Class AdCreatedEventArgs
Inherits EventArgs
Dziedziczenie
AdCreatedEventArgs

Przykłady

W poniższym przykładzie kodu pokazano, jak określić i kodować procedurę obsługi dla AdCreated zdarzenia. Pobiera on adres URL skojarzony z anonsem po utworzeniu AdRotator kontrolki i wyświetla go poniżej kontrolki. Ten przykład wymaga pliku XML (Ads.xml) wymienionego w poniższym przykładzie.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!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>AdRotator Example</title>
</head>
 
    <script language="c#" runat="server">
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {
          Message.Text=e.NavigateUrl;   
       }      
    </script>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="test1" runat="server"
            AdvertisementFile = "~/App_Data/Ads.xml"
            Borderwidth="1"
            Target="_blank"
            OnAdCreated="AdCreated_Event"/><br /><br />
 
       <asp:label id="Message" runat="server"/>
 
    </form>
 
 </body>
 </html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!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>AdRotator Example</title>
</head>
 
    <script language="vb" runat="server">
       Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 
          Message.Text=e.NavigateUrl
       End Sub
    </script>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="test1" runat="server"
            AdvertisementFile = "~/App_Data/Ads.xml"
            Borderwidth="1"
            Target="_blank"
            OnAdCreated="AdCreated_Event"/><br /><br />
 
       <asp:label id="Message" runat="server"/>
 
    </form>
 
 </body>
 </html>

W poniższym przykładzie kodu pokazano, jak sformatować plik XML zawierający informacje o anonsie. Aby uzyskać więcej informacji na temat pliku XML, zobacz AdvertisementFile właściwość AdRotator klasy.

<Advertisements>  
 <Ad>  
 <ImageUrl>image1.jpg</ImageUrl>  
 <NavigateUrl>http://www.microsoft.com</NavigateUrl>  
 <AlternateText>Microsoft Main Site</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic1</Keyword>  
 <Caption>This is the caption for Ad#1</Caption>   
 </Ad>  
 <Ad>  
 <ImageUrl>image2.jpg</ImageUrl>  
 <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>  
 <AlternateText>Wingtip Toys</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic2</Keyword>  
 <Caption>This is the caption for Ad#2</Caption>   
 </Ad>  
</Advertisements>  

<%@ Page Language="C#" AutoEventWireup="True" %>

<!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>AdRotator AdCreated Example</title>
</head>
 
   <script runat="server">

      void Page_Load(Object sender, EventArgs e)
      {

         // Create an EventHandler delegate for the method you want to handle the event
         // and then add it to the list of methods called when the event is raised.
         Ad.AdCreated += new System.Web.UI.WebControls.AdCreatedEventHandler(this.AdCreated_Event);

      }

      void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
      {

         // Override the AlternateText value from the ads.xml file.
         e.AlternateText = "Visit this site!";   

      }      

   </script>
 
<body>
 
   <form id="form1" runat="server">
 
      <h3>AdRotator AdCreated Example</h3>

      Notice that the AlternateText property of the advertisement <br />
      has been programmatically modified from the value in the XML <br />
      file. 

      <br /><br />
 
      <asp:AdRotator id="Ad" runat="server"
           AdvertisementFile = "~/App_Data/Ads.xml"
           Borderwidth="1"
           Target="_blank"/>
 
   </form>
 
</body>
</html>

<%@ Page Language="VB" AutoEventWireup="True" %>

<!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>AdRotator AdCreated Example</title>
</head>
 
   <script runat="server">

      Sub Page_Load(sender As Object, e As EventArgs)

         ' Create an EventHandler delegate for the method you want to handle the event
         ' and then add it to the list of methods called when the event is raised.
         AddHandler Ad.AdCreated, AddressOf AdCreated_Event

      End Sub

      Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 

         ' Override the AlternateText value from the ads.xml file.
         e.AlternateText = "Visit this site!"   

      End Sub      

   </script>
 
<body>
 
   <form id="form1" runat="server">
 
      <h3>AdRotator AdCreated Example</h3>

      Notice that the AlternateText property of the advertisement <br />
      has been programmatically modified from the value in the XML <br />
      file. 

      <br /><br />
 
      <asp:AdRotator id="Ad" runat="server"
           AdvertisementFile = "~/App_Data/Ads.xml"
           Borderwidth="1"
           Target="_blank"/>
 
   </form>
 
</body>
</html>

Uwagi

Zdarzenie jest wywoływane, gdy kontrolka AdCreatedAdRotator wyświetla anons na stronie.

Aby uzyskać listę początkowych wartości właściwości dla wystąpienia programu AdCreatedEventArgs, zobacz AdCreatedEventArgs konstruktor.

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Konstruktory

AdCreatedEventArgs(IDictionary)

Inicjuje nowe wystąpienie klasy AdCreatedEventArgs.

Właściwości

AdProperties

IDictionary Pobiera obiekt zawierający wszystkie właściwości anonsu dla aktualnie wyświetlanej anonsu.

AlternateText

Pobiera lub ustawia alternatywny tekst wyświetlany w kontrolce AdRotator , gdy obraz anonsu jest niedostępny. Przeglądarki, które obsługują funkcję Etykietki narzędzi, wyświetlają ten tekst jako etykietkę narzędzia dla reklamy.

ImageUrl

Pobiera lub ustawia adres URL obrazu do wyświetlenia w kontrolce AdRotator .

NavigateUrl

Pobiera lub ustawia stronę sieci Web do wyświetlenia po kliknięciu kontrolki AdRotator .

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też