ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code

Servers / Setup
Host Reviews
Server Setup
Error Tips

Contract ASP
Development

Intro to ASP



 
ASP Intro Ebook


The ASP On Line Course:
Writing Output in ASP

One of the first things to learn in ASP is how to create output. With a few simple commands, you can write out the current date and time, the user's browser information, and much, much more!

How does this work? Well, remember, ASP itself isn't ever visible to the user, It works behind the scenes. ASP can, however, display regular HTML tags, and text, and other HTML commands to the user's browser. The user's browser then interprets them as regular HTML and displays them just as if you had hard coded that information into a page.

What do I mean? Well, say you wanted the words

Hello, World

to appear to someone coming to the page index.asp. Let's say you wanted to use ASP to display those words. First, you would start with the "starting ASP" indicator. You always use this before you give any ASP commands, so your browser knows that what is coming next shouldn't be shown to the user.

<%

The <% is the way the browser knows to switch to 'ASP mode' where it starts processing what you tell it to do. Now you want to give the ASP command to write out some text. So you would put:

Response.Write "Hello, World"

That line tells the ASP interpreter to take the text "Hello, World" and write it out to the browser. You end with the 'end of command' marker -

%>

and that's it! So your entire file, with the normal HTML starting and ending, would look like this:

<HTML>
<BODY>
<%
Response.Write "Hello, World"
%>
</BODY>
</HTML>

That's it, you've done your first ASP page! Wasn't that easy? But heck, if you were just going to write "Hello, World", you wouldn't need ASP to do it. The great part about ASP is that you can write ANYTHING ASP knows about, which includes results from calcuations, retrievals from database queries, and much, much more.

Let's say you have a page in which you have all sorts of other HTML, and then at one spot you decide you want to show the user the current date and time. You can't code that into a web page, because it's always changing! However, since ASP is interpreted as the page is being displayed, IT always knows what time it is. So instead of putting

THIS IS THE CURRENT TIME

you would put

<%
Response.Write Now()
%>

and when the program ran, it would show the current time! There are MANY applications for writing with ASP. I'll cover a lot of specific examples in upcoming articles.

Free Online ASP Course


ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2009 Minerva WebWorks LLC. All rights reserved.

French Wedding


Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error