ASP
/ VBScript
1.
What is ASP?
ASP is an acronym for Active Server Pages.
Basically it is VBScript (a scripting language)
although any language can be used. Scripts
are written to perform functions on data
such calculations and manipulation. No special
development tools are needed to write or
view the code. Unlike JAVAScript and HTML
ASP is processed and executed on the server.
So any execution of the code must take place
remotely or on a locally installed Personal
Web Server (PWS).
2. How Files Are
Interpreted
Normally, HTML files are "interpreted"
on the client side (in a user's web browser).
With Microsoft's Active Platform, the server
can also interpret files. Interpreting to
a server means that before displaying a
file in a user's browser, the server will
complete some initial steps:
It will look at the
file's extension. If the file has a standard
extension, such as .html or .htm, the server
will pass the file to the browser. If the
file has an extension of .asp (or .asa),
the server will open the file and look for
tags that mark ASP code. ASP code is contained
inside special tags: <% before the code
begins and %> after it ends.
The server evaluates
the code contained inside these tags and
replaces it with HTML code. This HTML code
is generated based on information about
the user's setup or other conditions on
the client side.
The resulting page,
which contains some of the file's original
markup and some markup that has been generated
with ASP, is sent to the browser that requested
it.
Let's take the example of a shopping cart.
Imagine a customer has selected five items
from the store's catalog. These selections
are listed together on one "shopping
cart" page, which contains a table
with rows and columns. At the top of each
column is a heading, such as quantity, description,
stock number, or price. How will you construct
this page, considering that parts of it
are dependent on what the customer has chosen?
Back
to top
The column headings
can be included in the original HTML layout,
since they won't change. The table's position
probably won't change either, so it can
also be incorporated into the original HTML
file. These elements of the page will remain
the same, regardless of how many times you
come back and view the page.
The information inside
the table (the list of what has been selected
for purchase) will change, however. Each
person viewing the site may select a different
set of items. To display this information,
ASP pulls the item information from a database
and adds that item information to the HTML
layout before it is sent back to the user's
browser. Programmers use the term "on
the fly" for this type of page, because
it doesn't exist on its own. Instead, it
is created on demand ("on the fly")
when needed. The ASP script creates the
entire page, by combining the static page
elements with selected information from
the database.
3. Use, Installation
and Management of PWS
Click
here for detailed installation instructions
and screen shots!
If you are running Windows
95/98 then you will probably need PWS to
run Asp pages. PWS stands for Personal Web
Server. If you have the Windows CD then
you can install PWS from there. Or if you
want then you can download the latest version
of Personal Web Server from www.microsoft.com.
Installation is all very easy. Just run
the setup file and PWS will install just
as any other application is installed on
your system. Accept the defaults when it
comes to giving the location as to where
the 'inetpub' and 'wwwroot' directories
should be installed. Back
to top
4.
VBScript Date.
5.
VBScript Month.
6.
VBScript time.
7.
Date and time used together.
8.
Are you old enough?
9.
Password check.
10. Create a VBScript
Content Rotator
A content rotator consists of 2 different
components:
The content schedule file and the CONTENTROTATOR
OBJECT.
Sample content
schedule file (Save as scheduler.txt):
%%
// Picture 1
<img src="image1.jpg>
<H2> Image Number 1</H2>
<HR>
%%
// Picture 2
<img src="image2.jpg>
<H2> Image Number 2</H2>
<HR>
Back
to top
Copy and paste
the text to add more images to the rotation.
This is created as a separate file and saved
with the file extension of .TXT. You can
use a weight number to specify how often
you want the content to be displayed compared
to the other sections. For instance a weight
of 10 will display twice as often as a weight
of 5. The code looks like this:
%%
#5 // Picture 1
<img src="image1.jpg>
<H2> Image Number 1</H2>
<HR>
%%
#10 // Picture 2
<img src="image2.jpg>
<H2> Image Number 2</H2>
<HR>
ContentRotator Object
The VBScript to add to your web page to
display the images follows. Place the code
in the body of the document where you want
the images to appear.
<%
Set rotating=Server.CreateObject("MSWC.ContentRotator")
Response.Write(rotating.ChooseContent("scheduler.txt"))
%>
Back to top
11. Creating an Ad
Rotator
An ad rotator consists of 3 different components
just unlike the content rotator:
The ad schedule file, redirection file and
the ADROTATOR OBJECT.
Sample ad schedule
file (Save as rotator.txt) :
REDIRECT
redirection.asp
Width 468
Height 60
*
banner1.gif
http//www.msn.com
Visit MSN Online!
3
banner2.gif
http://www.yahoo.com
Visit Yahoo online!
2
banner3.gif
http://www.junglia.com
Visit Junglia online!
1
The
ad schedule file is created as a separate
file and saved with the file extension of
.TXT.
You can use a weight number to specify how
often you want the ad to be displayed compared
to the other ads. Back
to top
Sample
Ad Redirection File (save as redirection.asp)
<%
Response.Redirect(Request.QueryString("URL"))
%>
Sample
AdRotator Object (Place in the area
you want the ad to appear)
<%
Set advertisement=Server.CreateObject("MSWC.AdRotator")
Response.Write(advertisement.GetAdvertisement
("rotator.txt"))
%>
12.
Create a MadLib
Use the QueryString below to transfer the
text field entry:
<%
Response.Write(Request.QueryString("xxxxxx"))
%>
13. Passing
QueryStrings Part 2
<%
Response.Write(Request.QueryString("xxxxx"))
%>
<input type="hidden" name="xxxxx"
value="<%
Response.Write(Request.QueryString("xxxxx"))
%>">
14. Turning
the QueryString into a link
<form
name="form2" method="get"
action="xxxxxx.asp">
<td class="content"> <a
href="#" onclick="document.form2.submit();return
false">
<%
Response.Write(Request.QueryString("xxxxx"))
%>
</a>
</td>
</form>
Back
to top
|