iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 15, 2008
Reader Question - Would you host your client's work on your website?
About
 
May 15, 2008
How to Create an Ajax Autocomplete Text Field: Part 6
WebReference.com
 
May 14, 2008
Poll: Are the browser safe colors still needed?
About
 
May 14, 2008
Google Doctype launched
About
 
May 14, 2008
Web Editor Reviews - 6 New Reviews
About
 
May 14, 2008
Build Beautiful Buttons in Photoshop, Part I
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /ASP.NET

Using Built-In ASP Components 

  Views:    9102
  Votes:    0
by Andrew Schools 4/06/04 Rating: 

Synopsis:

In this tutorial, we will be working with three of Microsoft's built-in ASP components. The Ad Rotator, Content Linker and the Browser Capabilities Component.
Pages: firstback2 3 forwardlast
The Article

What's a Component?

A component is just a piece of code someone wrote so you wouldn't have to re-invent the wheel. Just like when you create a subroutine, you use the same code over and over again instead of having to re-write virtually the same piece of code somewhere else.

Why use Components?

Components make programming easier. You don't have to use components, but you will be creating much more work for yourself then needed.

Using the Ad Rotator Component

What's the Ad Rotator Component? Just what is says. It rotates your ads for you. In order to use this component, you will need three things:

  1. The rotator schedule file (text file)
  2. ASP page that redirects the user
  3. The ASP page that houses the banners

First, let's create the schedule file. A schedule file will have the following format:

schedulefile.txt

redirect.asp

width

height

border

*

ImageURL

HomePageURL

AltText

Weight

Image2URL

HomePage2URL

AltText

Weight

The first 4 lines of code apply to all banners.

The first line of code tells the browser what file to go to once the banner it clicked. This could be a redirecting script that logs all hits out from your site.

The second and third lines of code affects the width and height of the banners while the fourth line of code sets a border width around the image.

The fifth line of code (*) indicates where the first section of the file stops and the second starts.

ImageURL is the path of your banner

HomePageURL is the URL that the user is taken to when they click on the banner. This URL is passed to the redirect URL for processing. If there is no site to be taken to, then a hyphen (-) should be used.

AltText is used to display text instead of an image if the image doesn't load.

Weight is a number between 0 and 10,000 that indicates how many times the ad should be display compared to all other banners in the schedule file. For instance, if you had two banners in the schedule file with the weight of 1o and one banner with the weight of 20, the banner with weight 2o would be shown more times then the first two banners.

Here's a live example:

schedulefile.txt

REDIRECT out.asp

WIDTH 468

HEIGHT 60

BORDER 1

*

ex_pro.gif

http://www.batpros.com

BatPros

20

banner0291.jpg

http://www.wavenom.com

Wavenom

20


Now on to the redirection page. This page will redirect the user to the appropriate site when a banner is clicked.

The Ad Rotator creates a querystring for us to use. When a user clicks on a banner, we will get a querystring with the following information:

redirect.asp?url=homepageURL&image=imageURL  

So if we want to redirect the user to the appropriate site, we would use the following line of code:

redirect.asp

<% Response.Redirect Request.QueryString("URL")%>  

The last file we need to create is the ASP page(s) that will display the banners.

index.asp

<%

Dim objAdRotator

Set objAdRotator = Server.CreateObject("MSWC.AdRotator")

%>

<HTML><HEAD>

<TITLE>My Site </TITLE>

</HEAD><BODY>

Please support this site!<BR>

<%= objAdRotator.GetAdvertisement("schedulefile.txt") %>

Set objAdRotator = Nothing

<BR>Welcome to my site!!!

</BODY></HTML> 

This page displays our banners. If you refresh this page several times, you will see that a different image is displayed. Sometimes, especially with fewer banners to display, the same banner will appear.

The first couple of lines of code creates an instance of the Ad Rotator object and gives it the name of objAdRotator.

To display our image, we use the following code like shown above:

<%= objAdRotator.GetAdvertisement("schedulefile.txt") %>  

As you can see, our object uses the method GetAdvertisement() with the property of the name of our schedule file.

Pages: firstback2 3 forwardlast

Similar/related articles:


 
  Sponsors