Build a Simple Web Page with ASP
From LoveToKnow Web-Design
In order to build a simple web page with ASP (Active Server Pages) there are a lot of not-so-simple processes to go through first. ASP is one of the first technologies developed on the internet for dynamic, rather than static, web pages. Pioneered by Microsoft, Active Server Pages are created by scripting processes that take place on the server, rather than in the client's web browser. This makes the type of web browser the client is using irrelevant.
Code to Build a Simple Web Page with ASP
By placing the burden of processing on the server-side of the interaction, this means that the first requirement is an ASP-ready server. Usually this would be a server installed with Microsoft's Internet Information Services (IIS), although Sun has a product called Chili!Soft ASP which enables ASP to run on other non-Microsoft servers such as Apache, Red Hat, and others.
While these servers interpret HTML pages in much the same as any other server, pages with the suffix ".ASP" get treated differently. These pages have HTML, but they also have elements that are coded using a tool such as VBScript, with functions that are executed by the server and then added back into the HTML of the web page in order to finally display it on the client's browser. Theoretically, since all the processing is done by the server, it will display the same on all browsers – the holy grail of any web page design.
ASP Code Framework
While tools like VB Script certainly make creating ASP websites easier, like any code it is also possible to write the code with nothing more than a text editor. It's as simple as creating the correct syntax that the IIS server will recognize and process, and then labeling the final page with the suffix ".ASP" so that this page is flagged as needing special processing.
The framework for the page is similar to an HTML-based page, with <HTML>, <HEAD> and <BODY> tags as one would expect. Visual and meta elements such as keywords or bgcolor work exactly the same as well. However, writing ASP scripts, some new elements need to be entered into the code.Writing ASP Script
First of all, every ASP element needs to be enclosed in special tags: <% (then the ASP code) %>. Elements within the code also need to be given their own labels as well. For example, to set a "dimension variable" one would first use the code "Dim" (stating that a dimension variable is coming) and then naming the variable itself (something intuitive to the designer, such as "simpleVar").Once a variable is declared (you don't need to declare the data type, VBScript only has one type) you have to do something with it. It is simply a data container, so you load data into the variable as follows:
simpleVar = "This Message is being written using VBScript"
That puts the string This Message is being written using VBScript into the variable, but we still need to do something with it. That's where special commands come in. For example, Response.Write tells the server to take the variable and insert it into the HTML before sending the page down the HTTP stream:
Response.Write (simpleVar)
You can also use Response.Write to insert html tags like <BR> into the page, or even to call up server functions such as Time()" and many others. At the end of the ASP functionality, though, it's important, as always, to close tags properly: %> .Final Words
If this seems like a lot of work to do something that you could do much more simply using straight HTML, it's because this is only one example of how ASP and VBScript work. A real ASP site would use variables that would change based on user input or other factors, using the power of ASP to create a dynamic and responsive site.
However, it takes a lot of study in order to get to the point where you can use those tools effectively. Aside from the Microsoft site itself, there are other sites such as the Web Wiz Guide that feature tutorials about many of the ways to use ASP.
Learn More
This page has been accessed 783 times. This page was last modified 18:49, 9 December 2008.
© 2006-2009 LoveToKnow Corp.
Visit us on facebook