JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Ad Rotators

Visual Basic Web applications even support banner ads, which, as mentioned earlier, is something Internet purists may not be happy to hear. These ads, which all Internet users are familiar with, are image files in GIF, JPEG, or other formats, that the user can click to cause the browser to navigate to the advertiser's Web site.

Using an ad rotator, you can automatically cycle through a series of ad banners. The ad rotator automates the cycling process, changing the displayed ad when the page is refreshed. Note also that ads can be "weighted" to control how often they appear compared with others. And, if you prefer, you also can write custom logic that cycles through the ads.

You can see an ad rotator at work in Figure 18.4 and in the AdRotators example on the CD-ROM (shamelessly displaying an ad for this book). When you click the button in this example, the page reloads and displays various ads.

Click To expand
Figure 18.4: The AdRotators example.

There are two ways to specify the ad banners for an ad rotator—you can use an XML file or write your own code to select an ad banner in the AdCreated event. Here's what the XML file, ads.xml, for the AdRotators example on the CD-ROM looks like. You can see that for each ad, I'm specifying the URL of the ad banner, the URL to navigate to if the user clicks the ad, the alternate text to display if the ad banner isn't available (this text is also used as a tooltip, as you see in Figure 18.4), the number of impressions (the number of times the ad should be shown), and a keyword to use in selecting ads (you can use the KeyWordFilter property to filter ads for target audiences):

<Advertisements>
     <Ad>
         <ImageUrl>banner1.jpg</ImageUrl>
         <NavigateUrl>http://www.coriolis.com</NavigateUrl>
         <AlternateText>Coriolis VB.NET Black Book: Buy it now!
         </AlternateText>
         <Impressions>80</Impressions>
         <Keyword>VB.NET</Keyword>
     </Ad>

     <Ad>
         <ImageUrl>banner2.jpg</ImageUrl>
         <NavigateUrl>http://www.coriolis.com</NavigateUrl>
         <AlternateText>Coriolis Perl Black Book: Buy it now!
         </AlternateText>
         <Impressions>80</Impressions>
         <Keyword>Perl</Keyword>
     </Ad>

     <Ad>
         <ImageUrl>banner3.jpg</ImageUrl>
         <NavigateUrl>http://www.coriolis.com</NavigateUrl>
         <AlternateText>Coriolis HTML Black Book: Buy it now!
         </AlternateText>
         <Impressions>80</Impressions>
         <Keyword>HTML</Keyword>
     </Ad>
 </Advertisements>

And now it's time to turn to the Immediate Solutions section of this chapter, to see how to handle specific details.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor