ASPAlliance Home
Advertise with us
About Prasad KVNM
Refer this Site
                                               
Home Advertisement Management Systems KV's Kool ASP
Search
Samples/Articles
Convert URLs into Hyperlinks

Advertisement Management Systems

AdRotator Component

Extending AdRotator Component

Simple Alternative to AdRotator

A more powerful Ad Management System

Opinion Poll

Suggestions/Snippets
Passing Special Characters through URL

Date delimiter for Access and SQL Server

CDBL instead of CSNG

Handling Database Errors

Avoid Partial Updates to the Database

Book Review
C# and the .NET Platform

Favorite Links
ASPLists.com
ASPNG.com
Computer Dictionary
LearnASP.com

Microsoft .NET
Search @ Google
Wrox Press
Freecode.com

Site by Prasad KVNM,
New Jersey, USA
prasad@kunisetty.com
last updated on
22nd Oct, 2001



A Simple Alternative to AdRotator Component

Now you are creating your own advertisement system without using AdRotator component. It's very easy to buildup and extend it to a more complex system.

First you need to create the following asp file that contains the advertisement processing logic.

<!-- Beginning of adServe.asp file -->

<%

PUBLIC FUNCTION showAd() 

' The following line specifies how many advertisements do you have.
totalAds = 3

' The following lines are to Initialize random-number generator and to produce a random number based on the value of totalAds variable.
Randomize
adCode = Int((totalAds * Rnd) + 1)

SELECT CASE adCode

        CASE 1

                url = "http://www.aspalliance.com"
                image = "http://www.aspalliance.com/pkvnm/advt/banners/mybanner.gif"
                altText = "ASPAlliance"

        CASE 2

                        url = "http://www.telugupeople.com"
                        image = "http://www.telugupeople.com/advt/banners/tpladeng1.gif"
                        altText = "Telugupeople.com" 

        CASE 3

                url = "http://www.bbcworld.com"
                image = "http://www.aspalliance.com/pkvnm/advt/banners/second.gif"
                altText = "BBC World"

END SELECT

showAd = "<a href='" & url & _
"'><img src='" & image & "' alt='" & altText & "' border='0'></a>"

END FUNCTION

%>

<!-- End of adServe.asp file -->

Your advertisement system is ready. Just call it into your page. Following code shows how to display an advertisement using the above advertisement system.

<!-- Beginning of adServeRun.asp file -->

<!-- #include file ="adServe.asp"-->

<%=adCode%>

<!-- End of adServeRun.asp file -->

That's it!

See this example working live!

It displays advertisements in random order. You may change this logic. 

Also, this displays the advertisement directly. You can use a redirection page to store click-through information. See here to find how to use a redirection page.

Change the last line in adServe.asp file shown above as follows, if you want to use a redirection page:

showAd = "<a href='adRedir.asp?url=" & _
"'><img src='" & image & "' alt='" & altText & _
"' border='0'></a>"

If you want to open the advertisement in a new window, Change the last line in adServe.asp file shown above as follows:

showAd = "<a href='" & url & _
"'><img src='" & image & "' alt='" & altText & _
"' border='0' target='_blank'></a>"

See here to find how to extend this simple system using a database.

Back to: Advertisement Management Systems - Overview



Refer this site ASPAlliance.com |  Contact Us |  Join |  Advertise |  Best Viewed with IE 4.0 or above