ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Advertising --> Part 2: Serving the banners

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
134 active users
3025 visitors today
2948 pages today
(only part of today)
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
ASPRSS
ShawThing

Now open source with SourceForge!

Serving the ads

In Part 1 I loaded the ads for the day into Application variables for fast database-free access. Now I'll use those variables to display the ads:

// ============================================
// show the next available advertisement
// ============================================
function ShowAd ( )
{
   var nBanners = Application ( 'TotalBanners' );

   if ( !nBanners )
      return;

   // increment banner counter
   Application.Lock ( );

   if ( ++Application ( 'CurrentBanner' ) >= nBanners )
      Application ( 'CurrentBanner' ) = 0;

   Application.Unlock ( );

   // output banner html
   Out ( '<center>' + Application ( 'Banner' + Application ( 'CurrentBanner' ) ) + '</center>' );
}

This code is in utils/banners.asp. Calling the ShowAd( ) function outputs the HTML that I stored away in the Application variables earlier. The first step is to make sure I have some ads stored - if not then the function returns, having done nothing.

Next the Application is locked so I can increment yet another Application variable - "CurrentBanner". This variable is incremented until it is greater than the maximum number of banners, then it is reset to start again from zero.

I then reference the relevant Application variable to output the banner code. "Banner0", then "Banner1", etc.

This is a very simple banner rotation system! It currently allows no weighting, no zones and takes no notice of the user watching or the page it is displayed on. All these things can change if demand warrants it of course!

Now let's go back and investigate BannerCounter.asp - the file that counts impressions and manages the clickthroughs.

Part 3: Managing impressions and clickthroughs...

Featured sponsor
My favorite resources

Selling products online - read how James does it now



Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...