pport Training
Appendices
Lab 1: Introduction to Active Server
Objectives
What You Will Learn
After completing this lab, you will be able to:
Create basic script examples, demonstrating how to associate code with events or run inline.
Create a script that combines client side and server side scripting.
Related Topics Covered in this Lab
Client Side Scripting
Microsoft Confidential
May 2012
pport Training
Appendices
Before You Begin
Prerequisites
This lab requires that Microsoft Internet Information Server version 4.0 is installed on the local machine
Estimated time to complete this lab: 30 minutes
Microsoft Confidential
May 2012
pport Training
Appendices
Exercise 1
Comparing Client Side and Server Side Scripts
In this exercise, you will create client side and server side script files, comparing the behavior of each.
The purpose of this exercise is to demonstrate similarities and differences between server script and client
script, not code structure. Exercises in subsequent lessons will focus on more closely on the code.
1. To create the client side script example:
Launch NOTEPAD.EXE and insert the following code example into a new document.
<HTML>
<BODY>
This is a simple VBScript Demo.
It calculates the number of days until the end of the year.
<Script Language="VBScript">
Dim iTargetYear, dTargetDate, iDateDiff
iTargetYear=Year(Date())
dTargetDate=DateSerial(iTargetYear,12,31)
iDateDiff=DateDiff("d",Date(),dTargetDate)
Msgbox "Today's date is " & Date()
Msgbox iDateDiff & " more days to year end."
End Sub
-->
</Script>
</Body>
</HTML>
Save the file as C:\INETPUB\WWWROOT\CLIENTDEMO.HTM.
Launch Microsoft Internet Explorer and test the sample by browsing
HTTP://LocalHost/CLIENTDEMO.HTM. Allow the program to complete, dismissing the message
box by clicking the button marked “OK”.
In IE, view the HTML source of the client program by selecting the Source menu item from the View
menu.
What information is available in the Source? Is the script code visible? With what event is the script
associated (hint: look at the name of the sub procedure).
Microsoft Confidential
May 2012
pport Training
Appendices
2.
To create the server side script example:
Launch NOTEPAD.EXE and insert the following code example into a new document.
<HTML>
<BODY>
This is a server ASP Demo.
It calculates the number of days until the end of the year.
<BR>
<BR>
<%
Dim iTargetYear, dTargetDate, iDateDiff
iTargetYear=Year(Date())
dTargetDate=DateSerial(iTargetYear,12,31)
iDateDiff=DateDiff("d",Date(),dTargetDate)
Response.Write "Today's date is " & Date() & ".<BR>"
Response.Write iDateDiff & " more days to year end."
%>
</BODY>
</HTML>
Save the file as C:\INETPUB\WWWROOT\SERVERDEMO.ASP.
Launch Microsoft Internet Explorer and test the sample by browsing
http://localhost/SERVERDEMO.ASP. Allow the program to complete, dismissing the message box by
clicking the button marked “OK”.
In IE, view the HTML source of the client program by selecting the Source menu item from the View
menu.
What information is available in the Source? Is the script code visible? Will the script run if the
extension of the file is changed to HTM?
Microsoft Confidential
May 2012
pport Training
Appendices
3.
To combine server side and client side scripting:
Launch NOTEPAD.EXE and insert the following code example into a new document.
<HTML>
<BODY>
This is a simple client/server Demo that calculates the number of days
until the end of the year.
<BR>
<BR>
<%
Dim iTargetYear, dTargetDate, iDateDiff
iTargetYear=Year(Date())
dTargetDate=DateSerial(iTargetYear,12,31)
iDateDiff=DateDiff("d",Date(),dTargetDate)
%>
<Script Language="VBScript">
MsgBox "Today's date is <%=Date()%>."
MsgBox "<%=iDateDiff%> more days 'til year end."
End Sub
-->
</Script>
</BODY>
</HTML>
Microsoft Confidential
May 2012
upport Training
Properties
71
Error Handling
Erl
Error
On Error...Resume
Resume, Resume Next
File Input/Output
All traditional Basic file I/O
Financial
All financial functions
Object Manipulation TypeOf
Objects
Clipboard
Collection
Operators
Like
Options
Deftype
Option Base
Option Compare
Option Private Module
Category
Omitted Feature/Keyword
Select Case
Expressions containing Is keyword or any comparison
operators
Expressions containing a range of values using the To
keyword.
Strings
Fixed-length strings
LSet, RSet
Mid Statement
StrConv
Using Objects
Collection access using !
â 1997 Microsoft Corporation. All rights reserved.
Microsoftđ Visual Basicđ Scripting Edition
VBScript Features not in
Visual Basic for
Applications
Language Reference
Contents
Category
Formatting strings
Intrinsic constants
Microsoft Confidential
Feature/Keyword
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
MonthName
WeekdayName
vbGeneralDate
vbLongDate
vbLongTime
vbShortDate
vbLongDate
vbTristateFalse
vbTristateMixed
vbTristateTrue
May 2012
upport Training
Properties
Objects
Rounding
Strings
Script Engine Identification
72
vbTristateUseDefault
Dictionary
FileSystemObject
TextStream
Round
Filter
InstrRev
Join
Replace
Split
StrReverse
ScriptEngine
ScriptEngineBuildVersion
ScriptEngineMajorVersion
ScriptEngineMinorVersion
© 1997 Microsoft Corporation. All rights reserved.
Microsoft Confidential
May 2012