Ask the Wireless Pro 10-Minute Solution

Creating Banner Ads for Wireless Sites
By Jeromy Hill

In an earlier 10-Minute Solution, "Making Dynamic Content Available via ASP", I showed you how to develop an application using Active Server Pages to produce WML. There are other applications of server-side programming (ASP) that output directly to WML. For example, in this Solution, I show you how to develop a rotating banner ad system for Wireless devices.
 
Figure 1: A banner ad display

Figure 1 shows a possible way to display banner ads on a WAP site. This screen shot comes from the beta release of Nokia's new WAP toolkit. (You can give the wireless Web surfer an opportunity to click the banner ad by adding that functionality to the left soft key on the phone.)

For the purposes of this demonstration, let's assume I want to create an application that puts a banner ad at the top of any page that includes it. I'm going to be using VBScript to generate my ASP. To add scalability, I'm going to pull all the relevant information from a database, thereby making the generated content dynamic. I'll randomly select an entry from the database and then display that information. It's possible to "cycle" through ads, but for this demonstration I'm going to pull up one entry randomly. Each time the page loads, a new ad will be displayed.

Here's an overview of my imaginary database structure. A primary key, bannerid, is sequential in TBL_ADINFO, a table from the larger database. Other fields in that table are bannertext and bannerURL. Bannertext contains the actual text message of the banner ad and bannerURL includes a click-through link, if needed. I could also include a graphic, but for simplicity, I'll leave that out.

<%@Language=VBScript

' Defining a constant for the randomizer
MaxNoAds = 10

' Setting our content type
Response.ContentType = "text/vnd.wap.wml"

' Randomly selecting an entry from the database
Randomize(Cbyte(Left(Right(Time(),5),2)))
AdID=(Int((MaxNoAds-1+1) * Rnd + 1))

' Pulling information from the database

set objConn = Server.CreateObject("adodb.connection")
objConn.Open "dsn=adserver;uid=adserver"
sql = "SELECT * from TBL_ADINFO where bannerid = '" & AdID & "'"
set rsAd = objConn.Execute(sql)

' Displaying the WML content
%>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 
"http://www.wapforum.org/DTD/wml_1.1.xml"> 
<wml>
<card id="bannerad" title="Ad">
<p>
 <a href="<%=rsAd("bannerURL")%>"> <%=rsAd("bannertext")%>
</p>
</wml>
Now that I've created the guts of the system, I can go ahead and implement it. On every page that I want to have a banner ad, I simply do an include, as follows:
<!--- #include file="bannerad.asp" --->
Now I've got my banner ads!

Return to Get Help with Wireless Dev Page

Return to Main Get Help Page
 
Other 10-Minute Solutions
 Anatomy of a WAP Site
 Writing Java for the Palm
 Configuration of IIS for WML MIME Content Types
 Making Dynamic Content Available via ASP
 Building a Web Clipping Application
 Examining the Wireless Telephony Application Interface
 Using XML Stylesheet Language Transformations
 Creating Banner Ads for Wireless Sites
 Taking a Look at the WAP Stack's Security Level
 Create Novel Wireless Features with Refresh and Timer Tag Combinations
 Visually Enhancing Wireless Web Sites
 Creating Controls by Hand in the .NET Compact Framework


Sponsored Links


Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers