468,535 Members | 1,711 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ


What is ASP?

By Robert Murdock
Programmer, Darpac Inc.

Lesson One: Basics

This article assumes that you have installed and are familiar with IIS and the options package and have a basic knowledge of HTML. If you have not already installed the options pack that can be found at www.microsoft.com.

What are Active Server Pages (ASP)?

ASP is a DLL which resides on the server. It will parse the ASP commands and allow you as the programmer to create server-side scripts thus allowing a web page to be altered (or created dynamically) before being sent to the user.

All of your asp pages will need to be saved with a .ASP extension. This will be filtered though the ASP DLL automatically.

What are some of the advantages of ASP? Most people believe that is much faster to create fully functional service side scripts in ASP then say CGI. You are able to connect to a database with just a few lines of code or mix and match ASP and HTML. Another big advantage is the flexibility of how you write the code. Most people use VB SCRIPT or JSCRIPT. Examples I use will concentrate on VB SCRIPT.

Now lets get started!

Since ASP will allow you to choose the syntax you develop with you will to define this to allow the interpreter to know what language you are using. I have not seen an ASP page fail without this but it's good practice to add it. At the top (first line) of you ASP page you show add:

<@ LANGUAGE="VBSCRIPT" %>

or

<@ LANGUAGE="JSCRIPT" %>

Basic Syntax:

The ASP.DLL is specifically looking for code that is place in between <% and %>. Any text in between these designators will be parse by this DLL as code. You are able to mix and match this code.

Example (example1.asp):

<@ LANGUAGE="VBSCRIPT" %>
<HTML>
<TITLE>My First ASP!</TITLE>
<BODY>
<CENTER>My First ASP!
<BR>
<% Response.Write("I am well on my way to learning ASP!") %>
<BR>
All done!</CENTER>
</BODY>
</HTML>

The first four lines are standard HTML. Line five is where the ASP code starts (note the "<%"). Here an object was inserted. The Response.Write object allows text (or HTML code) to be passed back from the server to the client. What will the output look like? Type it in and give it a try!

Comments:

To write a comment in VB all you have to do is add a single tick inside of an ASP code segment.

Example (example2.asp):

<@ LANGUAGE="VBSCRIPT" %>
<%
'This is a comment.
'Nothing after a tick will be seen by the user
'as it is not processed
'by the server.
%>

Note that we did not use any HTML code. Loading this page will create a valid HTML page, however, in practice you should always use the HTML, TITLE, and BODY tags when creating a page that will show output to a user. Pages that will redirect a user, etc. will not need these tags.

  ASP Variables »