AdCreatedEventArgs Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
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
- Ereditarietà
Esempio
Nell'esempio di codice seguente viene illustrato come specificare e codificare un gestore per l'evento AdCreated . Ottiene l'URL associato all'annuncio quando il AdRotator controllo viene creato e lo visualizza sotto il controllo. Questo esempio richiede il file XML (Ads.xml) elencato nell'esempio seguente.
<%@ 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>
Nell'esempio di codice seguente viene illustrato come formattare il file XML contenente le informazioni sull'annuncio pubblicitario. Per altre informazioni sul file XML, vedere la AdvertisementFile proprietà della AdRotator classe .
<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>
Commenti
L'evento AdCreated viene generato quando il AdRotator controllo visualizza un annuncio nella pagina.
Per un elenco dei valori iniziali delle proprietà per un'istanza di AdCreatedEventArgs, vedere il costruttore AdCreatedEventArgs.
Per ulteriori informazioni sulla gestione degli eventi, consultare gestione e generazione di eventi.
Costruttori
| Nome | Descrizione |
|---|---|
| AdCreatedEventArgs(IDictionary) |
Inizializza una nuova istanza della classe AdCreatedEventArgs. |
Proprietà
| Nome | Descrizione |
|---|---|
| AdProperties |
Ottiene un IDictionary oggetto che contiene tutte le proprietà dell'annuncio pubblicitario per l'annuncio attualmente visualizzato. |
| AlternateText |
Ottiene o imposta il testo alternativo visualizzato nel AdRotator controllo quando l'immagine dell'annuncio non è disponibile. I browser che supportano la funzionalità Descrizioni comando visualizzano questo testo come descrizione comando per l'annuncio. |
| ImageUrl |
Ottiene o imposta l'URL di un'immagine da visualizzare nel AdRotator controllo . |
| NavigateUrl |
Ottiene o imposta la pagina Web da visualizzare quando si fa clic sul AdRotator controllo . |
Metodi
| Nome | Descrizione |
|---|---|
| Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
| GetHashCode() |
Funge da funzione hash predefinita. (Ereditato da Object) |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |