Componente ASP AdRotator


Componente ASP AdRotator

Il componente ASP AdRotator crea un oggetto AdRotator che visualizza un'immagine diversa ogni volta che un utente accede o aggiorna una pagina. Un file di testo include informazioni sulle immagini.

Nota: AdRotator non funziona con Internet Information Server 7 (IIS7).

Sintassi

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

Esempio di ASP AdRotator

Supponiamo di avere il seguente file di testo, chiamato "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

Le righe sotto l'asterisco nel file di testo sopra specificano il nome delle immagini (annunci) da visualizzare, gli indirizzi dei collegamenti ipertestuali, il testo alternativo (per le immagini) e le percentuali di visualizzazione (in percentuale).

La prima riga del file di testo sopra specifica cosa succede quando un visitatore fa clic su una delle immagini. La pagina di reindirizzamento (banners.asp) riceverà una querystring con l'URL a cui reindirizzare.

Suggerimento: per specificare l'altezza, la larghezza e il bordo dell'immagine, puoi inserire le seguenti righe in REDIRECT:

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

Il file "banners.asp" si presenta così:

Esempio

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

È tutto!!



Proprietà di 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"))
%>

Metodi 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"))
%>