Beginning Active Server Pages

Before you start

Before you start
A few points before getting coding

  • Active Server Pages runs as part of PWS (Personal Web Server) on Windows 9x and NT Workstation, and IIS (Internet Information Server) on NT Server and Windows 2000. PWS and IIS on NT Server can be found in the NT 4 Option Pack. IIS comes as standard on Windows 2000. It will NOT run on Unix.
  • When you create an ASP page, you cannot view it on your harddisk by going to C:MyWebmyasppage.asp. It won't work! That references a direct page on your hard disk, and the server doesn't get a chance to parse any of the ASP code.
  • If you have IIS installed, it means your PC is a server (even if your PC is the only one which can access it)! You can access the pages on the server at http://localhost/ or http://PCName/. The physical location of your web site is by default C:\inetpub\wwwroot. Save your ASP pages there, and view them in a browser by visiting the URLs above.

Anyway, lets take a first look at some ASP code. Unsurprisingly, an asp page has the extension asp. In this file, you can place standard HTML. VB code can then be placed within two tags, <% and %>. As a quick example, save the following text to a file with an asp extension:

<p>This is HTML</p>
<%
'This is Visual Basic code
Response.Write "<p>hello</p>"
%>

As you can see, an ASP page is a combination of HTML and Visual Basic. Don't worry too much about the new keywords used just yet. All the Response.Write does is 'prints' "<p>hello</p>" to the rest of the page. In fact, by the time it reaches the browser, it would look like this:

<p>This is HTML</p>
<p>hello</p>

VB vs Active Server Pages

  • Standard Visual Basic Syntax Identical
  • Most standard VB 6 functions such as InStr and Replace are present
  • In Active Server Pages, you can't set the data type of a variable. The language processor decides this at run-time. (This can take some time getting used to for 'well behaved' programmers - fortunately, the Option Explicit statement remains)
  • Goto and On Error Goto statements are not supported
  • You don't compile Active Server Pages. They remain as source code, which is then parsed each time the page is executed
  • You can't display UI components such as form or message boxes
  • You can use ActiveX controls, although most users security settings will prevent them from running.
  • You can't edit ASP pages in Visual Basic. You can either edit them in notepad, Visual InterDev (part of the Visual Studio package), Developers Pad, or another programming editor

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“You can stand on the shoulders of giants OR a big enough pile of dwarfs, works either way.”