Beginner's Guide to ASP Programming with a Sample Program

Beginner's Guide to ASP Programming with a Sample Program
Page content

Moving from Static to Dynamic Sites

On the Internet there are two types of web sites – static and dynamic. A static web site is composed of a series of HTML files linked together to present information to a user but there’s no interaction. Web designers often refer to these types of sites a “brochure” sites because the user can only read the information that’s being displayed. In the early days of the Internet, static web sites comprised the bulk of the information on the World Wide Web. Today however there is an increasing need for interactivity between a web site and it’s users. These types of dynamic web sites are what allow us to do online banking, make plane or hotel reservations, look up information through search engines, design ecommerce or member’s only web sites or just gather information from our visitors.

Active Server Pages is One Solution

There are a number of programming languages that can be used to create a dynamic web site and one of these is through Active Server Pages (ASP). Active Sever Pages allow you to write server-side scripts that add interactive functionality to your web site. We call these server-side scripts because the code is processed and executed on the web server and then all the ASP code is stripped out of the page and a pure HTML files is returned to the browser. Because only HTML is sent back the page works with any browser running on any computer.

NOTE: Before selecting a programming language to use on your web site you first need to contact your web hosting service to see what languages they support. Some common ones are ASP, PHP and ASP.NET.

Sample ASP Code for Beginners

Active Server Pages are normally written in VBScript, a stripped down version of Visual Basic. ASP pages have a .asp file extension instead of the typical .htm or .html extensions. ASP code can be written inside of an HTML page or kept in a separate file and then included into your HTML page. A simple ASP page may look like this:

Sample.asp

My First ASP Page

This is a sample ASP page

Today is <%= Date()%> and the time now is <%=Time ()%>

The first thing you may notice are the <% and %> symbols mixed in with the standard HTML code. These are called ASP delimiters. These delimiters separate the server-side code from the HTML tags. When a web page is executed on the server it goes through the page looking for any code you have written and then the code is compiled and run. In the example above the web page is returned to the user with the current date and time displayed.

Other Important Tips

Before you get started writing your first ASP page there are a couple things you need to know. ASP is not a software package, it’s a technology that’s build into the web server. In order for you to use this technology your web hosting service must support it. Typically only Windows web servers support ASP however there are 3rd party programs that can be installed on Unix and Linux web servers to allow you to create ASP pages. You will need to check with your web host before you get started. Also, because ASP pages are run on a server you can write them on your local PC however you will need a web server, such as Microsoft Internet Information Server (IIS), installed to be able to test them out locally. If you’re running Windows XP professional or Widows Vista Home Premium (or higher) then you can install IIS by going to the Control Panel, Add/Remove Programs, Windows Components.

As with any programming language, there are too many topics to cover in a single article but if you’re interested in adding some interactivity to your web site there are a number of tutorials and sample code site on the Internet that you can use to learn from. You may want to start by visiting ASP101 (https://www.asp101.com/) and trying some of the samples that they have there.