Starting with ASP
So far I have not shown you one piece of ASP and we are already onto the
fourth page. So it is about time this changed! What we are going to do
here is look at ASP, take some very small first steps and look at the
standard components that come with ASP. This will set you up for the first
proper, in-depth look at ASP in ASP training.
What Does ASP Look Like
ASP uses scripts inside HTML pages to do the work. ASP can use a number
of different flavours of script to do its work, VBScript (Visual Basic
Script), JavaScript and PerlScript are three of the common ones. The whole of
this site was written using VBScript (VBs) and this is what we shall be
using for all of the training. If you want to use a different flavour of
script, the application I will use to training you will provide you with links
to other sites with that contain this information.
A First Script
Below is a first, basic ASP script, I have coloured the ASP specific elements red (and the comments in green)
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Demo ASP page</TITLE>
</HEAD>
<BODY>
<h1>just some standard html</h1>
<%
response.write("using asp to write to the page")
'PROGRAMMERS NOTE
'the line terminator in VBs is the carriage return!
'lets tell everyone what day of the week it is!
'get the current date
currentDate = Date
'extract the day of the week information
weekDayValue = weekday(currentDate)
'work out what the value is in real money
'PROGRAMMERS NOTE
'you could do this with a CASE statement
'so if you feel brave look up the SELECT CASE
'and use that instead of the big if
if weekDayValue = 1 then
weekDayActual = "Sunday"
elseif weekDayValue = 2 then
weekDayActual = "Monday"
elseif weekDayValue = 3 then
weekDayActual = "Tuesday"
elseif weekDayValue = 4 then
weekDayActual = "Wednesday"
elseif weekDayValue = 5 then
weekDayActual = "Thursday"
elseif weekDayValue = 6 then
weekDayActual = "Friday"
elseif weekDayValue = 7 then
weekDayActual = "Saturday"
else
weekDayActual = "Ooops, something's not right here!"
end if
%>
<p>
Today is <b><i><%= weekdayActual %></i></b>
</BODY>
</HTML>
So, a nice and simple ASP script (which you can cut and paste and use on
your own machine if you wish). You
can see this script working on this site.
This script will form the basis of the first part of the ASP training section, and
each detail will be looked at there. For now, the purpose of this script
is to give you an idea of what ASP looks like in the raw! You can see that
the ASP it interlaced with ordinary HTML. You can tell where the ASP
specific stuff starts and ends by the <% (open) and %> (close) tags,
which are very much like the <> and </> tags in HTML (that I hope you
are already familiar with.