8:52 am Wednesday, August 20, 2008


  Navigation
  Help?
Contact Aaron for all inquiries.
 

  News

ASP Inline Calendar 3.9 Beta 1
ASP Games
ASP Inline Corporate Calendar 3.8 BETA 1 Demo
Calendar Updates
 

A Better World By Design
 
  Creating Your First ASP Page Tutorial
AaronOutpost : ASP / Tutorials / ASP 101 / Mix ASP with HTML

ASP 101: Mix ASP with HTML
By: Aaron B. Copyright AaronOutpost.com

 

    This is part 2 of 6 of ASP 101 by AaronOutpost.com. If you are unsure of what we may be talking about in the tutorial, view the previous parts.

So far we have created your first ASP page and we have defined a value and displayed it on the page. We are now going to take that exact same page and modify it. I am going to show you how to mix ASP with HTML.

Let's begin.

 

Part 2:
Mix ASP with HTML

START YOUR PAGES

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

Open first_asp_page_part1.asp, the file we created in the previous tutorial. Your code should look like this.

<html>

<head>

<title>My First ASP Page</title>

</head>

<body bgcolor="#FFFFFF" 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>

 

HOW TO MIX ASP WITH HTML

You will notice that you can end the ASP script %> and go back to HTML. You can actually do this and still keep your stored variables.

Also, in the middle of html code you can enter ASP. Say you are in the middle of html code and you want to enter your value. Simply open ASP script, put and equals sign and then the variable. Of course end the asp script to return back to HTML.

<%= MyVariable) %>

 

 

 

Now knowing this, let's change our existing page to use more html and not the response.write function.

<html>

<head>

<title>My First ASP Page</title>

</head>

<body bgcolor="#FFFFFF" 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!"
%>

<br><br>
<font face="Arial" size="2" color="#000000">
<%
= MyVariable %></font>

</body> </html>
 

CONGRATULATIONS!!!

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

Open Viewable Example
Continue to part 3: Date & Time Functions

 


AaronOutpost : ASP / Tutorials / ASP 101 / Mix ASP with HTML



Aaron Outpost West Virginia, USA A Mark of _-Squire-_ Creations Inc.  CopyrightŠ 2005 All Rights Reserved