SUMMARY
This article describes how to use the Ad Rotator installable component for Active Server Pages (ASP) in Microsoft FrontPage.
NOTE: You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets (< and >) may appear as escaped HTML code (< and >). To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage.
(
Back to top)
Creating a Rotator Schedule File
A rotator schedule file is a specialized list of advertisements to display. A double percentage sign denotes the separation of each advertisement section and a double slash indicates a comment.
For additional information, see the
Rotator Schedule File Syntax section later in this article. For additional information about the formatting you can use in this file, see the
References section later in this article.
- Start FrontPage. Open a Web on a Web server based on Microsoft Internet Information Services (IIS).
- On the Standard toolbar, click the New Page button.
- Click the HTML tab at the bottom of the FrontPage window to switch to HTML view.
- On the Edit menu, click Select All. Press DELETE to delete all of the existing text.
- Type the following text:
REDIRECT redir.asp
WIDTH 200
HEIGHT 100
BORDER 1
*
http://www.microsoft.com/library/homepage/images/mslogo-blue.gif
http://www.microsoft.com/
Click here for advertisement #1
1
http://msimg.com/w/logo.gif
http://www.msn.com/
Click here for advertisement #2
1
http://www.msnbc.com/i/cov/b.gif
http://www.msnbc.com/
Click here for advertisement #3
1
- On the File menu, click Save.
- In the Save as type list, click All Files (*.*).
- In the File name box, type AdRotator.txt and then click Save.
- On the File menu, click Close.
(
Back to top)
Creating a Redirection Page
Although a redirection file is not necessary, it allows you to track a customer's actions. For example, you can create a database to log how many times a specific advertisement is selected. To do this, perform the following steps:
- On the Standard toolbar, click the New Page button.
- Click the HTML tab at the bottom of the FrontPage window to switch to HTML view.
- On the Edit menu, click Select All. Press DELETE to delete all of the existing text.
- Type the following text:
<%@Language="VBScript"%>
<%Response.Redirect(Request("URL"))%>
- On the File menu, click Save.
- In the Save as type list, click All Files (*.*).
- In the File name box, type redir.asp and then click Save.
- On the File menu, click Close.
(
Back to top)
Creating the Ad Rotator Component
- On the Standard toolbar, click the New Page button.
- Click the HTML tab at the bottom of the FrontPage window to switch to HTML View.
- Insert the following code before the opening <body> tag:
<%
Dim objAdRotator
Set objAdRotator = Server.CreateObject("MSWC.AdRotator")
%>
This code creates the Ad Rotator component you will use later. - Click the Normal tab at the bottom of the FrontPage window to switch to Normal view.
(
Back to top)
Inserting the Ad Rotator Component on the Page
- Insert an HTML Markup Web component and then add the ASP code that uses the ad rotator object. To do this, perform the following steps:
- On the Insert menu, click Web Component.
- In the Component type list, click Advanced Controls.
- In the Choose a control list, click HTML.
- Click Finish.
- In the HTML Markup dialog box, type the following code:
<%=objAdRotator.GetAdvertisement("AdRotator.txt")%>
This ASP code retrieves a text entry from the rotator schedule file you created earlier. - Click OK to close the HTML Markup dialog box.
(
Back to top)
Saving and Previewing the Page
- On the File menu, click Save.
- In the File Name box, type AdRotatorTest.asp and then click Save.
- On the File menu, click Preview in Browser.
- Click Preview.
- Preview the page in your Web browser.
When you refresh the page in the Web browser, the advertisement changes.
(
Back to top)
MORE INFORMATION
What are Installable Components?
You can create dynamic, interactive Web pages by using the components included with Active Server Pages (ASP) in your scripts. Two built-in components are Response and Request objects. Installable components also are included with IIS.
(
Back to top)
Rotator Schedule File Syntax
NOTE: The syntax for this file is rather specialized, but easy to customize. The general format for this file is shown in the following table:
Line Value 1 Value 2 Description
------------------------------------------------------------------------
1 REDIRECT [URL] Specifies the path to the .asp file that
implements redirection.
2 WIDTH [Number] Width of the advertisement on the page,
in pixels. The default is 440 pixels.
3 HEIGHT [Number] Height of the advertisement on the page,
in pixels. The default is 60 pixels.
4 BORDER [Number] Width of the hyperlink border around the
advertisement, in pixels. The default is
a 1-pixel border.
5 * Signifies the end of the global
information section.
A1 [Image URL] The URL location of advertiser A's image
file.
A2 [Page URL] The URL location of advertiser A's home
page.
A3 [Text] Alternate text that is displayed if the
browser does not support graphics.
A4 [Number] A number between 0 and 10000 that
indicates the relative weight of
advertisement A.
B1 [Image URL] The URL location of advertiser B's image
file.
B2 [Page URL] The URL location of advertiser B's home
page.
B3 [Text] Alternate text that is displayed if the
browser does not support graphics.
B4 [Number] A number between 0 and 10000 that
indicates the relative weight of
advertisement B.
To add additional advertisements, add the four lines that define an advertisement: Image URL, Page URL, Alternate Text, and Relative Weight. For additional information, see the
References section later in this article.
(
Back to top)