1. ACTIVE SERVER PAGES
Active Server Pages (ASP), also known as Classic ASP
or ASP Classic, was Microsoft's first server-side script
engine for dynamically generated web pages. Initially
released as an add-on to Internet Information Services
(IIS) via the Windows NT 4.0 Option Pack, it was
subsequently included as a free component of Windows
Server. ASP.NET has superseded ASP.
The Active Scripting engine's support of the
Component Object Model (COM) enables ASP websites
to access functionality in compiled libraries such as
DLLs.
2. The use of ASP pages with Internet Information Services
(IIS) is currently supported on all supported versions of
IIS.
Web pages with the .asp file extension use ASP, although
some web sites disguise their choice of scripting
language for security purposes Pages with the .aspx
extension use compiled ASP.NET which makes them
faster and more robust than server-side scripting in ASP,
which is interpreted at run-time; however, ASP.NET
pages may still include some ASP scripting. The
introduction of ASP.NET led to use of the term Classic
ASP for the original technology.
3. VBSCRIPT
Using VBScript in ASP pages is very simple. The interpreter
replaces all the code in between the <% and %> tags. In the
example below Response.Write Now() dynamically replaced
by the current time of the server.
<html>
<head>
<title>Kaushik Enterprises</title>
</head>
<body>The server's current time:<br />
<%
Response.Write Now()
%>
</body>
</html>
4. VBScript is not case sensitive
foo is the same thing as FOO
This applies to everything
variable names, constant names
keywords
subroutine/function names
object names
5. VBSCRIPT VARIABLES
Data type: variant
can be anything (much like JavaScript & Perl).
Some people name variables according to how they
will be used:
intFoo Foo is an int
strFoo Foo is a string
objFoo Foo is an object
6. VARIABLE SCOPE
Variables declared outside of a
subroutine or function (VBScript has
both) are global.
Variables declared in a subroutine or
function are created and destroyed
each time the procedure is called.
(local variables)
7. THE ACTIVE SERVER PAGES MODEL
• An ASP script begins to run when a browser requests
a .asp file from your Web server.
• Web server then calls ASP, which reads through the
requested file from top to bottom, executes any ASP
statements, and sends an HTML page to the browser.
9. ASP SCRIPTING
• The first line in an .asp file specifies the scripting
language for the page. For example, the following
first line in .asp file specifies that the script is
VBScript:
<%@ LANGUAGE=VBScript %>
• Without a language tag, script in the file is processed
as the default language (VBScript by default.) under
the ASP entry in the Web server registry.
• Active Server Pages can provide a scripting
environment for a number of other scripting
languages, including Jscript (build-in), REXX, and
Perl, and others.
11. SETTING UP ASP FILES
• An Active Server Pages (ASP) file is a text file with the
extension .asp that contains any combination of the following:
– Text
– HTML tags
– ASP script commands
– Call to ActiveX server components
• ASP is server-side scripting.
• ASP files only work with the IIS on NT or PWS on Windows
95.
• .asp files should be saved on your Web site in a directory that
has Script or Execute permission enabled.
12. DATA TYPES
• Variables: Simple variables and Array variables
• VBScript subsumes all categories of data under one name called a Variant.
• At a basic level, Variants contain either string or numeric data.
• String data is used for text, while numeric data contains only numbers.
• Variant data can be further classified into subtypes. For example, you can
have numeric data that represents currency, or a date or time, and the
Variant will interpret the data accordingly.
• You can use the data type conversion function for data type conversion. For
example, CInt function to force conversion of an expression to the Variant
of subtype Integer.
13. DECLARING VARIABLES
VBScript implicitly creates a variable the first time that it
encounters an unrecognized string of characters that could be a
variable name.
The Option Explicit statement informs VBScript to generate an
error if it encounters an undeclared variable. The Option Explicit
statement should be the first line of code in a script that uses
variables.
Dim varname[([subscripts])][, varname[([subscripts])]] . . .
Dim a, x(10), y(2, 5)
A variable name:
Must begin with an alphabetic character.
Cannot contain an embedded period.
Must not exceed 255 characters.
Must be unique.
Is not case-sensitive.
14. USE PROCEDURES TO STRUCTURED CODE
Structured code consists of compact chunks of related code that are
termed procedures.
Procedures are reusable code that can be called from anywhere in
your script.
The main benefits of structured coding are as follows:
Maintenance—when related code is grouped, it is easier to
maintain. When code needs to be updated or modified, you can
make the changes in a single code segment rather than
throughout an entire program.
Debugging—because the code is modular, you can pinpoint
where an error occurs and conduct your debugging efforts in the
code segment where the error occurred.
Reusability—you can call the procedures from anywhere in
your script, as well as use the code segments in other programs
that require the same procedures.
15. SCOPE OF A VARIABLE
• If a variable is declared outside of a procedure, it is
visible throughout the program.
• If a variable is declared inside a procedure, it is only
visible inside that procedure.
• The range of a variable’s visibility is called its scope.
• In VBScript:
– Scope is either script-level or procedure-level.
– A variable is in effect within its scope.
– Variable names must be unique within their scope.
– Variables should always be defined with the smallest scope possible.
16. WHAT IS AN OBJECT?
• An object is simply a collection of functions and data
grouped together. Typically, most of the object’s
functionality (particularly its data structure) is hidden
from the programmer, who uses the object’s interface, or
model, to control the object. The object’s interface
consists of a published set of functions and data. In pure
object-oriented systems, data are private and therefore
cannot be accessed by external object directly.
• Methods: The procedures that an object exposes through
its interface are called methods. Methods are typically
functions and return a value.
17. Properties: The variables that are part of an object are
called properties:
Reading a property’s value is called getting the property’s value.
Writing a value to a property is called setting the property’s value.
Properties can be read-only or read/write depending on the design of
the object.