Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 202,541 times

Contents

Related Categories

Beginning Active Server Pages - Before you start

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

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Re: [1010] Beginning Active Server Pages - absolute beginner!

    Posted by michael poxon on 16 Dec 2006

        Hi,
    When I say I'm an ASP beginner, I mean it! I've only written one trivial bit of code, and got a blank page. I see now that's described in the article snippet below. I did ind...

  • .I want to know how to save the files.whats the extensions...

    Posted by writetoksk on 04 Oct 2006

    hi,


    its first i started ASP.I want to know how to save the files.whats the extensions...Where can i get the sample programs

  • Posted by James Crowley on 28 Dec 2004

    Are you running IIS ? And are you viewing it in your browser via the correct URL? (ie something starting with http:// rather than file:// ) ?

  • Posted by James Crowley on 28 Dec 2004

    It does - you just can't see it ;) We've got an ISAPI filter that rewritse /show/1010/ to something like /show.aspx?id=1010

  • It's not working ;_;

    Posted by HyperHacker on 12 Dec 2004

    Is there something special I have to do besides saving it as a .asp file, or does it just not work on my server? It just spits out the code, even HTML, as plain text.

    [code]
    Let's see if ASP...