4:43 am Saturday, February 04, 2012
     
SERVER TRANSFER COMPLETE. UNDER CONSTRUCTION.
            Search About Contact Home
Creating Your First ASP Page Tutorial
AaronOutpost : ASP / Tutorials / ASP 101 / Create My First ASP Page

ASP 101: Create My First ASP Page
By: Aaron B. Copyright AaronOutpost.com

 

    This tutorial will walk you through step-by-step of some of the basics to create your own ASP website and applications. I am going to assume you already know a little about HTML. If you don't, I suggest you check out my web design section to bring you up to speed on making html websites before you tackle ASP.

    First off, before you even to try to this exercise, Make sure you have read the article What is ASP? and understand. And if you understand it, then you should know that you have to have a server to run ASP scripts. So, if anything I have said confuses you, go back to the article What is ASP?

 Now that is out of the way. Let's begin.

Part 1:
Create My First ASP Page

START YOUR PAGES

Open your favorite text or HTML editor. It can be FrontPage, NotePad, FireWorks, Arachnophilia, etc... It don't matter.

Start off with your basic HTML page with any colors and such that you want but save the page as first_asp_page_part1.asp

<html>

<head>

<title>My First ASP Page</title>

</head>

<body bgcolor="#FFFFFF" text="#000000" link="#003300" vlink="#006600" alink="#689577">

</body>

</html>
 

 

 

STARTING AND ENDING ASP SCRIPT

Now we will start writing actual ASP scripts. To start ASP you have to use <% and likewise to end ASP codes you use %>

Simple Right?

 

COMMENTS

My first major rule in ASP coding to is leave yourself notes, so you if you come back later, you know what that part of the codes does. This has always been proper programmer etiquette. In ASP, this is called A "Comment". To initiate a comment, use the apostrophe mark followed by your comments. Comments can only be used inside ASP brackets. Otherwise, it will be displayed on the page as HTML coding.

<%

'My Comment is inside the ASP brackets
%>

 

DIMENSIONING VARIABLES AND COMMENTING

Many times later in your ASP progress you will use variables which you can define to be anything. Unlike VBScript on your computer, the newer ASP servers do NOT required variables to be dimensioned. However, using the dimension function allows you to add comments about that variable.

There are some predefined variables as well.

Let's start by Dimensioning our variables. Let's do a variable called MyVariable to hold some information. You can call it anything you want.

And using what we learned above, we will add a comment to remind us later what that variable is exactly. In large applications, the becomes very useful when going back and trying to work on the code.

<%

'Dimension variables

Dim MyVariable 'Comment on what this variable holds

Notice I haven't given the variable MyVariable a data type as you may traditionally do in VB programming. This is because VBScript only has variant as a data type.

 

GIVE A VARIABLE A VALUE

Now that we have a variable, Let's define it to be some text. You could of course define to be anything other than just text. Later you will learn how to get data out of databases and etc...

'Define a value for the MyVariable
MyVariable = "I am learning ASP! This is my first programmed variable!"

 

DISPLAY A VARIABLE USING RESPONSE.WRITE
Now that the variable has a value, to display it, we will use the Response.Write statement. I have used this statement thousands of times in my ASP Programs.

'Write MyVariable to the web page
Response.Write (
MyVariable)


You can use Response.Write to also insert normal HTML codes will in the middle of an ASP script. Let's go back, and add some html before our variable to add lines and a font style and size.

However, usually font tags begin <font style="verdana" size="1"> but you can't use " because that will denote the end of Response.Write so there are two ways to fix this problem.

Double Quotes "" or use an apostrophe mark '. I will show you both.

'Start a font tag and use double quotes
Response.Write ("<font face=""Arial"" size=""2"" color=""#000000"">")

 

'Start a font tag and use apostrophe
Response.Write ("<font face='Arial' size='2' color='#000000'>")

 

Let's go back, and add some html before our variable to add lines and a font style and size.

'Write line breaks into the web page
Response.Write ("<br><br>")

'Start a font tag and use double quotes
Response.Write ("<font face=""Arial"" size=""2"" color=""#000000"">")

Write MyVariable to the web page
Response.Write (
MyVariable)

'End a font tag
Response.Write ("</font>")


'Close the server script
%>

</body> </html>

 

 

CONGRATULATIONS!!!

Now, you have completed part 1 of 6 Learning ASP 101 by AaronOutpost.com.

Here what your final code should look like.
Open Viewable Example

Continue to part 2: ASP With HTML

<html>

<head>

<title>My First ASP Page</title>

</head>

<body bgcolor="#FFFFF" text="#000000" link="#003300" vlink="#006600" alink="#689577">

 

<%

'Dimension variables

Dim MyVariable 'Comment on what this variable holds

 

'Define a value for the MyVariable
MyVariable = "I am learning ASP! This is my first programmed variable!"

'Write line breaks into the web page
Response.Write ("<br><br>")

'Start a font tag and use double quotes
Response.Write ("<font face=""Arial"" size=""2"" color=""#000000"">")

'Write MyVariable to the web page
Response.Write (
MyVariable)

'End a font tag
Response.Write ("</font>")

'Close the server script
%>

  </body> </html>

 


AaronOutpost : ASP / Tutorials / ASP 101 / Create My First ASP Page
Random_Image
News & Updates

ASP Inline Calendar 3.9 (January 5, 2008)
Future Home of News & Updates (January 5, 2008)

 

Photo Special

Schedule an appointment

Available in & around:
Centreville VA, Spotsylvania VA,
Summersville WV, & Charleston WV
.

  • NAME YOUR PRICE
    • Email your:
    • Event
    • Hours Needed
    • Photos Needed
    • Disks or Prints
    • and Price You're Willing To Pay
ASP Inline Calendar

$100 Installation Special

PROFESSIONAL INSTALLATION OF YOUR ASP INLINE CALENDAR. REDUCE THE HASSLE, LET US INSTALL YOUR ASP INLINE CALENDAR. SEND A FORMAL REQUEST FOR INSTALLATION WITH SERVER ACCESS INFORMATION. WE WILL NEED FTP ACCESS ALONG WITH CONTROL PANEL ACCESS.

Purchase A Calendar
Information
Demo
Ask A Question

User must provide ftp access to server. Installations are not guaranteed. We work with your service provider to get your calendar installed.

 

Centreville, VA      -      Spotsylvania, VA      -      Charleston, WV      -      Summersville, WV

© Copyright AaronOutpost.com 2012. All rights reserved.