Date: |
July
15, 2001 |
Subject: |
Online
Programmer Ezine, Volume 2, No.6 |
Article: |
Start Programming in ASP, Part I - Your first ASP program |
- Intro -
ASP is a new scripting technology that comes with Microsoft
IIS web server and enables web programmers to create
powerful web applications and pages. These dynamic pages
are the result of running a code on the server. Server
receives user’s input from browser, runs the script and
creates a web page on the fly and sends it back to browser.
We can use different languages such as vbscript and jscript
with asp scripting method. ASP is now available on Unix
platforms by a third party company “chili soft”. For Unix
people asp is very similar to PHP scripting.
By learning ASP we will be able to write different
applications such as search engines, user databases, chat
scripts, message boards, web mail and any dynamic web
application that you see on the web.
- Your first ASP script -
ASP code is very similar to html code. Difference is that
some part of code contains scripting commands.
As we told latter, script languages that we can use in ASP
code can be vbscript, jscript, perlscript or any other
scripting language. Vbscript and Jscript are supported by
default in IIS (Microsoft’s Internet Information Server
that includes a web server). Other scripting languages
must be installed on server before you can use them.
Let’s look at our first example:
Example 1-1: “1-1.asp”
<html>
<%test="Hello"%>
<%=test%>World!
</html>
As the resulting web page will be a standard html file,
we have inserted <html> opening and closing tags in
our document.
Anything that comes between <%…%> tags is assumed to be
script will be run by scripting engine of IIS web server.
Here we have used the following command between <%...%>
tags:
test=”hello”
This command will create a variable and assign it the
value “hello”.
Whenever you want to print value of a variable or
expression you can use <%=…%> tags with variable name
or expression.
Here we have used the following:
<%=test%> world!
IIS will replace <%=test%> with actual value of variable
‘test’. Therefore result of this line of code will be:
Hello world!
If you want to run this code you must create a file with
.asp extension in a directory in your web servers root.
For example if your web server root is at
“c:\Inetpub\wwwroot”
then make a directory called “aspc” in “wwwroot” directory
and place “1-1.asp” file inside it.
After this step you must be able to run it from a browser.
Just point your browser to “http://localhost/aspc/1-1.asp”.
If you see the words “Hello world!” then you have succeeded.
If your browser tries to download asp file or an error
occurs then you must find the problem. Check file contents
and filename again. You must also have “script run” access
for “aspc” directory.
If browser shows an error, you may be able to find some
comments at the end of error page. These errors are
issued by web server and in most cases help you to find
scripting errors.
After you have succeeded running your first asp script,
we are ready to go to next step: “Learning ASP programming!”
- A little more -
If you have run the code you must have seen the results on
your web browser. If you want to see html source of browsed
page, you can right click on page and choose “view source”.
In this way you will be able to see what html code is
actually sent to your browser.
For our previous example you must see this code:
<html>
Hello world !
</html>
As you see your browser have received a standard html page.
As an asp code produces a new result each time it is being
run (most of them) we call this kind of web pages as
“Dynamic web pages”.
Enough for this part. You can continue studying in next
issue. Until then you can ask your questions in our ASP
programming forum at:
http://op.htmsoft.com/forums
|
| |