Active Server Pages

Another milestone technology—one discussed extensively in this book—is Active Server Pages, or ASP. In many ways, ASP is the most exciting of all the new Internet technologies because it allows you to create great, platform-independent content that can be used in any browser. Or, if you want to take maximum advantage of platform-specific technologies such as Dynamic HTML, you can create ASP pages that speak directly to Internet Explorer 4.0.

At its most fundamental, ASP is scripting done on the server. This scripting code is evaluated dynamically when the page is requested, and the resulting HTML is passed to the calling browser. Consider the code in Listing 1-6, which uses ASP to generate six successive lines of text that get increasingly larger.

Listing 1-6. An ASP Web page.


<%@SCRIPT LANGUAGE="VBSCRIPT"%> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Developer Studio"> <META HTTP-EQUIV="Content-Type" content="text/html;      charset=iso-8859-1"> <TITLE>ASP Example</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <%For x = 1 to 6%>     <FONT FACE="ARIAL" SIZE=<%=x%>>     ActiveX Is Cool!     </FONT>     <P> <%Next%> </BODY> </HTML> 

The sample code includes a <SCRIPT> tag, but notice that percent signs appear inside the brackets. This syntax indicates that the code is to be executed on the server before the page is downloaded to the client. In fact, notice the percent signs that surround all the code in the page. This code is all evaluated before the browser receives the page. The resulting HTML code looks like this:

<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Developer Studio"> <META HTTP-EQUIV="Content-Type" content="text/html;      charset=iso-8859-1"> <TITLE>ASP Example</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <FONT FACE="ARIAL" SIZE=1> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=2> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=3> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=4> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=5> ActiveX Is Cool! </FONT> <P> <FONT FACE="ARIAL" SIZE=6> ActiveX Is Cool! </FONT> <P> </BODY> </HTML> 

In the resulting HTML lies the beauty of Active Server Pages. ASP output can be limited strictly to HTML—understandable by any browser! This makes ASP an ideal choice for applications that must run on the Internet, where any browser can view a page. ASP is not limited to the lowest common denominator, however, and you can freely add client script, ActiveX controls, and Dynamic HTML to the output of ASP. ASP pages are therefore as flexible as you want them to be.



Programming Active Server Pages
Programming Active Server Pages (Microsoft Programming Series)
ISBN: 1572317000
EAN: 2147483647
Year: 1996
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net