Cet article a fait l'objet d'une traduction manuelle. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. |
Traduction
Source
|
AdCreatedEventArgs, classe
Assembly : System.Web (dans System.Web.dll)
Le type AdCreatedEventArgs expose les membres suivants.
| Nom | Description | |
|---|---|---|
|
AdCreatedEventArgs | Initialise une nouvelle instance de la classe AdCreatedEventArgs. |
| Nom | Description | |
|---|---|---|
|
AdProperties | Obtient un objet System.Collections.IDictionary qui contient toutes les propriétés de publication pour la publication affichée. |
|
AlternateText | Obtient ou définit le texte de remplacement affiché dans le contrôle AdRotator lorsque l'image de la publication n'est pas disponible. Les navigateurs qui prennent en charge la fonctionnalité Info-bulles affichent ce texte sous forme d'info-bulle pour la publication. |
|
ImageUrl | Obtient ou définit l'URL d'une image à afficher dans le contrôle AdRotator. |
|
NavigateUrl | Obtient ou définit la page Web à afficher lorsqu'un clic est effectué sur le contrôle AdRotator. |
| Nom | Description | |
|---|---|---|
|
Equals(Object) | Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.) |
|
Finalize | Autorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.) |
|
GetHashCode | Sert de fonction de hachage pour un type particulier. (Hérité de Object.) |
|
GetType | Obtient le Type de l'instance actuelle. (Hérité de Object.) |
|
MemberwiseClone | Crée une copie superficielle de l'objet Object actif. (Hérité de Object.) |
|
ToString | Retourne une chaîne qui représente l'objet actuel. (Hérité de Object.) |
L'événement AdCreated est déclenché lorsque le contrôle AdRotator affiche une publicité sur la page.
Pour obtenir la liste des valeurs de propriétés initiales d'une instance de AdCreatedEventArgs, consultez le constructeur AdCreatedEventArgs.
Pour plus d'informations sur la gestion d'événements, consultez Événements et délégués.
L'exemple de code suivant montre comment spécifier et coder un gestionnaire pour l'événement AdCreated. Il montre comment obtenir l'URL associée à la publication lorsque le contrôle AdRotator est créé et comment l'afficher sous le contrôle. Cet exemple nécessite le fichier XML (Ads.xml) énuméré dans l'exemple ci-dessous.
<%@ 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>
L'exemple de code suivant illustre la mise en forme du fichier XML contenant les informations relatives à la publication. Pour plus d'informations sur le fichier XML, consultez la propriété AdvertisementFile de la classe AdRotator.
<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>
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.