关闭

Asp JavaScript 教程 - Lesson 01 A General Overview

标签: aspjavascripthtmldocumentationmicrosoftoutput
841人阅读 评论(0) 收藏 举报
分类:
 

A General Overview

Before We Start:

ASP stands for Active Server Pages. ASP comes from Microsoft and it promises a language neutral platform on which to develop dynamic web pages.

Your Scripts are written as plain text and stored in files with the .asp extension. When called upon, your script goes through the ASP script engine, which combines your scripts with information from the web surfer, possibly a database, and other sources as you see appropriate.

Based on the presumptions laid out on the home page, I assume you already know how to create text files with an .asp extension. I also assume you already know how to place your files into a virtual folder. There is a lot of documentation on how to do these things, but the subject matter is beyond the scope of this web site.

Get Started:

The best way to get into this lesson is simply to dive right into the script.

Below is the ASP Script for Lesson 01.

<%@LANGUAGE="JavaScript"%>
<%
Response.Write("<HTML>")
Response.Write("<BODY>")
Response.Write("Hello World<BR>")
Response.Write("</BODY>")
Response.Write("</HTML>")
%>

Click Here to run the script in a new window.

Tags:

This is a pretty simple example. My bet is that you already get it. Have you noticed that ASP tags are similar to HTML tags? There is a difference. <%ASP Goes Here.%> The ASP tags use a percent sign.

@LANGUAGE:

The @LANGUAGE attribute is set to "JavaScript". That means ASP will run our scripts through the JavaScript (JScript) script engine.

Most servers are set by default to use VBScript. We can change the default language for a single page by using the @LANGUAGE attribute. @LANGUAGE must be set BEFORE any other ASP commands. So, it's a good idea to put @LANGUAGE right at the very top, even before your HTML headers. @LANGUAGE can only be set ONCE in any particular script. It should also stand alone; don't put any other command inside the same set of tags.

Misc. Notes:

Response is an ASP object (Not to be confused with JavaScript objects) and Write is an ASP method (not to be confused with JavaScript methods). Response gets its own lesson later on.

The last thing we need to notice on this script is the difference between the ASP script and the resulting HTML Script.

Below is the HTML source code as seen on the client side.

<HTML><BODY>Hello World<BR></BODY></HTML>

The Client Side output is all on one line. If you haven't already, click the link to run the script and then View Source Code. You will see that the entire HTML text is one unbroken line. That's bad. On lager pages, it will make the HTML output difficult to read. Trust me; you can't find bugs if you can't even make heads or tails of what you're putting out to the client.

In Lesson 02 we will fix that problem.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4083次
    • 积分:45
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:4篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档