VKS-LEARNING HUB

Home » Class XII » MMWT-XII » ASP-Component

ASP-Component

ASP Ad Rotator Component

The Ad Rotator component creates an Ad Rotator object that automates the rotation of advertisement images on a Web page. Each time a user opens or reloads the Web page, the Ad Rotator object displays a new advertisement based on the information you specify in a Rotator Schedule file.

You can record how many users click each advertisement by setting the URL parameter in the Rotator Schedule file to direct users to the Redirection file. When you specify this parameter, each jump to an advertiser’s URL is recorded in the Web server activity logs.

The Ad Rotator object relies on two additional files for parameters and functionality:

Redirection File. An optional file that implements redirection and enables you to record how many users click on each advertisement and save this information to a file on the server.

Rotator Schedule File. A text file that contains the display schedule and file information for advertisements. This file must be available on a Web server virtual path.

Syntax: ASP Ad Rotator Component

The Ad Rotator Control is registered with the ProgId of “MSWC.AdRotator”. The following VBScript excerpt shows creating an instance of the control.

Set adRot = Server.CreateObject( “MSWC.AdRotator” )

Properties: ASP Ad Rotator Component

  • ·   Border  
  • ·   Clickable  
  • ·   TargetFrame

 

In order to use this component we need a file with the ads we want to rotate in our page:

Adrot.txt code

REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0

*

/image1.gif
http://www.domain1.com/

Visit domain1.com

30

/image2.gif

http://www.domain2.com/

Visit domain2.com

70

In the first line we must include the character  “*”, and starting in second line, each four lines we will include information related to one ad (first ad in red, second ad in blue).

Information related to each ad must be write in four lines as shown above. Ad related information will be introduced in the order used in the example:

  • 1st line: location of image
  • 2nd line: click url
  • 3rd line: default text
  • 4th line: relative frequency for this ad

 

To display those ads in our page we will include the following code to our page (explanation in the bottom):

Souce Code Code Explanation
<%url=Request.QueryString(“url”)If url<>”” then Response.Redirect(url)%> <html>                                                                          <body>

<%

Set adrotator=Server.CreateObject(“MSWC.AdRotator”)

 ‘ Border of image

adrotator.Border=”0″

‘Image is a hiperlink or not

adrotator.Clickable=true

‘ Specify target

adrotator.TargetFrame=”target=_new”

‘ The link in included

response.write(adrotator.GetAdvertisement(“adrot.txt“))

%>

</body>
</html>

 Line 2 we will get the url corresponding to this adLine 3 visitor is redirected to the correct url(the script will stop here).Line 8 the object will be create.Line 10 the border of the image is defined

Line 12 if true it is a link, if false an

image will be shown but it will not be clickable.

Line 14- target frame or window is defined (a new window in this example).

Line 16  the link code is written in the page. This code will be obtained from our list of ads, so we need to indicate the path to that file.

Properties

Property Description Example
Border Specifies the size of the borders around the advertisement <%
set adrot=Server.CreateObject(“MSWC.AdRotator”)
adrot.Border=”2″
Response.Write(adrot.GetAdvertisement(“ads.txt”))
%>
Clickable Specifies whether the advertisement is a hyperlink <%
set adrot=Server.CreateObject(“MSWC.AdRotator”)
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement(“ads.txt”))
%>
TargetFrame Name of the frame to display the advertisement <%
set adrot=Server.CreateObject(“MSWC.AdRotator”)
adrot.TargetFrame=”target=’_blank'”
Response.Write(adrot.GetAdvertisement(“ads.txt”))
%>

Methods

Method Description Example
GetAdvertisement Returns HTML that displays the advertisement in the page <%
set adrot=Server.CreateObject(“MSWC.AdRotator”)
Response.Write(adrot.GetAdvertisement(“ads.txt”))

CONTENT ROTATOR

ASP Content Rotator Component

The ASP Content Rotator component creates a ContentRotator object that displays a different HTML content string each time a user enters or refreshes a page. A text file, called the Content Schedule File, includes the information about the content strings.

The content strings can contain HTML tags so you can display any type of content that HTML can represent: text, images, colors, or hyperlinks.

Syntax

<%
Set cr=Server.CreateObject( “MSWC.ContentRotator” )
%>

The following example displays a different content each time a user views the Web page. Create a text file named “textads.txt” in your default Web Site folder, in a subfolder called text.

“textads.txt”:

%% #1
This is a great day!!%% #2
<h1>Smile</h1>%% #3
<img src=”smiley.gif”>%% #4
Here’s a <a href=”http://www.vinodsrivastava.wordpress.com”>link.</a&gt;

Notice the #number at the beginning of each content string. This number is an optional parameter that indicates the relative weight of the HTML content string. In this example, the Content Rotator will display the first content string one-tenth of the time, the second string two-tenths of the time, the third string three-tenths of the time, and the fourth string four-tenths of the time.

Then, create an ASP file, and insert the following code:

<html>
<body><%
set cr=server.createobject(“MSWC.ContentRotator”)
response.write(cr.ChooseContent(“text/textads.txt”))
%></body>
</html>

The ASP Content Rotator Component’s methods are described below:

Methods

Method Description Example
ChooseContent Gets and displays a content string <%
dim cr
Set cr=Server.CreateObject(“MSWC.ContentRotator”)
response.write(cr.ChooseContent(“text/textads.txt”))
%>Output:
GetAllContent Retrieves and displays all of the content strings in the text file <%
dim cr
Set cr=Server.CreateObject(“MSWC.ContentRotator”)
response.write(cr.GetAllContent(“text/textads.txt”))
%>Output:smiley


This is a great day!!


Smile

smiley



Here’s a link.


 


Leave a comment