ASP is a programming language developed by Microsoft. It is used to process
forms, work with databases, develop ecommerce applications, and more.
ASP
embeds programming code on a web page. The pages
are stored
on
a server. When a user requests a particular page, the server processes
all the code on the page, and returns the result to the end user. All the
user
recieves
is a simple HTML page, without any ASP code. This might sound a little puzzling
right now, but it will be very clear at the end of this lesson.
- Start Dreamweaver and open a blank web page.
- Change to CODE VIEW, so you can see all the HTML code on a page.
- Add this line to the very top of the page, right above <html>.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
- Place the following block of code between the </head> and <body> tags.
<%
varA = 4
varB = 4
Answer = varA + varB
%>
- Everything between the <% and %> marks will be processed
on the server.
- Add the following line between the <body> and </body> tags.
<% =Answer %>
- Save the page to your xHTML folder as FirstPage.asp. You will
have to type in the .asp extension.
- You cannot view this page locally. You must upload it to the server,
and view it "live" to make it work. (In other words, type in the full path
to get to your server space -- http://nlecommerce1.dcccd.edu/students/semester/xhtml/FirstPage.asp.
Be sure to replace the semester with the current semester and year.
- The resulting page is pretty boring. It has an 8 on it. That's all.
- Now what we need to do is look at the HTML code on this page. This can
be accomplished several ways, depending on your browser. Most browsers
have a View > Source Code menu
choice. If yours doesn't you can try saving the page to your hard drive,
and opening it in either Dreameaver or the Windows Notepad.
- Notice that all our ASP code -- everything between the <% and %> marks -- is not
on the page. All of this code was processed by the server. When the server
finished processing the code, it returned a nice, clean HTML-only page.
- This has several benefits, including
- Improved security -- users cannot see your fancy ASP code
- Speed -- sometimes ASP pages have very long programs, and sending
the entire page across the Internet would take a great deal of time.
Instead, the server processes the page and sends the user a shorter
HTML-only page.
ASP has several other benefits, including the ability to work with databases
and specialized programming objects called COM objects. We'll play with COM
objects in the third ASP lesson.