Composant ASP AdRotator


Composant ASP AdRotator

Le composant ASP AdRotator crée un objet AdRotator qui affiche une image différente chaque fois qu'un utilisateur entre ou actualise une page. Un fichier texte contient des informations sur les images.

Remarque : AdRotator ne fonctionne pas avec Internet Information Server 7 (IIS7).

Syntaxe

<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>

Exemple d'AdRotator ASP

Supposons que nous ayons le fichier texte suivant, nommé "ads.txt":

REDIRECT banners.asp
*
w3s.gif
https://www.w3schools.com
Free Tutorials from W3Schools
50
xmlspy.gif
https://www.altova.com
XML Editor from Altova
50

Les lignes situées sous l'astérisque dans le fichier texte ci-dessus précisent le nom des images (publicités) à afficher, les adresses des liens hypertexte, le texte alternatif (pour les images) et les taux d'affichage (en pourcentage).

La première ligne du fichier texte ci-dessus spécifie ce qui se passe lorsqu'un visiteur clique sur l'une des images. La page de redirection (banners.asp) recevra une chaîne de requête avec l'URL vers laquelle rediriger.

Conseil : Pour spécifier la hauteur, la largeur et la bordure de l'image, vous pouvez insérer les lignes suivantes sous REDIRECT :

REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3s.gif
...

Le fichier "banners.asp" ressemble à ceci :

Exemple

<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>

<!DOCTYPE html>
<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("textfile.txt"))
%>
</body>
</html>

C'est tout!!



Propriétés ASP AdRotator

Property Description Example
Border Specifies the size of the borders around the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Border="2"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
Clickable Specifies whether the advertisement is a hyperlink <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
TargetFrame Name of the frame to display the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.TargetFrame="target='_blank'"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>

Méthodes ASP AdRotator

Method Description Example
GetAdvertisement Returns HTML that displays the advertisement in the page <%
set adrot=Server.CreateObject("MSWC.AdRotator")
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>