README.md

December 5, 2022 · View on GitHub

Intro to ASP syntax

Description

Attention ASP newbies! Looking to create your first ASP page? Check out this tutorial!

More Info

Submitted On
ByBrad Hess from http://www.4aspdev.com
LevelBeginner
User Rating4.0 (28 globes from 7 users)
CompatibilityASP (Active Server Pages)
CategoryComplete Applications
WorldASP / VbScript
Archive File

Source Code

Let’s code our first ASP page. To do this write out the following code in your choice of development environment.

<HTML>
    <
BODY>
        <
B>Welcome to my webpage hosted on PWS!B>
        <BR>The time is now: <%=Response.Write(TIME())%>
        <
BR>
     BODY
>
HTML>

Save the file in the c:\Inetpub\wwwroot\ directory on your machine and name it default.asp. Try accessing your website by opening a browser and typing http://127.0.0.1/default.asp or http://yourmachinename/default.asp. 127.0.0.1 is what is called the loopback address and is the TCP\IP address that points at your machine. The text: Welcome to my webpage hosted on PWS! should now show up. On the line under you should read "The time is now:" followed by the current time. Like this only without the Back link. If the time is showing up correctly you have a working ASP server running on your PC!. If the time does not show up correctly then something is wrong with the installation of personal web server

Now that we have an ASP page. Lets look at what is really happening when the page is requested. The code is as follows

<HTML>
    <
BODY>
        <
B>Welcome to my webpage hosted on PWS!B>
        <BR>The time is now: <%=Response.Write(TIME())%>
        <
BR>
     BODY
>
HTML>

The code color syntax is the same as you will see in Interdev and Frontpage.  Most of the code in this page is plain HTML, however the inside  <% and %> is ASP code.  The <% and %>  seperates the HTML code from ASP code.  The server recognizes the <% and %> and processes anything contained inside.  Response.Write calls the Response Object that is part of the ASP object model. The write part of response.write calls the write method of that object. I will expand upon this more in the future. TIME() is recognized by the script engine as a function that retrieves the current time.

You just created your first dynamic website every time it is requested it will be updated with the current time on the server. While this is not really helpful it works well as an example.

See my next tutorial on the ASP object model to get a better idea of what all ASP supports.