当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP 语法

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP 语法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 892 ::
收藏到网摘: n/a

You cannot view the ASP source code by selecting "View source" in a browser, you will only see the output from the ASP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
你不能通过浏览器上的“查看-源文件”选项来直接获取ASP的源代码,(因为ASP代码和脚本程序要事先在服务器上进行解读执行;随后,服务器再将ASP代码解读完毕之后的结果以“HTML数据流”的形式发送到浏览器),所以你看到的只是将ASP转化为HTML形式的内容,而不能直接获取ASP源代码。

In our ASP tutorial, every example displays the hidden ASP source code. This will make it easier for you to understand how it works.
在我们的ASP教程中,每一个例子都会将ASP的源代码展示出来,这更有助于你理解ASP的工作原理。


 

Examples
实例

Write text with ASP
用ASP书写文本
How to write some text with ASP.
如何用ASP书写一些文本

Add some HTML to the text
向文本中加入HTML标签
How to format the text with HTML tags.
如何往文本中写入HTML标签


 

The Basic Syntax Rule
ASP基本语法规则

An ASP file normally contains HTML tags, just like an HTML file. However, an ASP file can also contain server scripts, surrounded by the delimiters <% and %>. Server scripts are executed on the server, and can contain any expressions, statements, procedures, or operators valid for the scripting language you prefer to use.
一个ASP文件通常包含HTML标签,有时和一个HTML文件非常类似。然而,ASP文件(除了包含HTML标签外),还可以包括服务器的脚本程序,这些脚本程序必须写在“<%”和“%>”界定符号(服务器读到这个界定符号就知道以下是ASP程序,“<%”表示ASP程序开始,“%>”表示ASP程序结束)之间。ASP的脚本程序在服务器端解读执行。这些脚本程序可以包括所有你想要用到的表达式、语句、程序和有效的运算符。


 

Write Output to a Browser
将结果输出到浏览器

The response.write command is used to write output to a browser. The following example sends the text "Hello World" to the browser:

<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>

There is also a shorthand method for the response.write command. The following example also sends the text "Hello World" to the browser:
下面这个例子和“Response.Write”指令的作用完全相同,是“Response.Write”指令的一种简化形式,它同样也会将“Hello World!”这段话发送到浏览器:

<html>
<body>
<%="Hello World!"%>
</body>
</html>


VBScript
VBScript脚本

You can use several scripting languages in ASP. However, the default scripting language is VBScript:
你可以在书写ASP代码时使用一些脚本语句。ASP默认的脚本语句是“VBScript”:

<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>

The example above writes "Hello World!" into the body of the document.


JavaScript
JavaScript脚本

To set JavaScript as the default scripting language for a particular page you must insert a language specification at the top of the page:
如果你需要使用“JavaScript”脚本作为默认的脚本语句来编写一些特殊的ASP网页,那么,你需要在网页的顶部插入一段语句来规定整个网页默认的脚本语句,具体如下:

<%@ language="javascript"%>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>

Note: Unlike VBScript - JavaScript is case sensitive. You will have to write your ASP code with uppercase letters and lowercase letters when the language requires it.
注意:我们前面所讲的“VBScript”脚本语句是一种对字母大小写不敏感的脚本语句,即:response.write / Response.Write / ReSpoNSe.WRiTe ,这些全部都是有效的;但是,如果你用“JavaScript”脚本语句书写ASP代码的话,你就要对字母的大小写加以区别,因为“JavaScript”脚本语句是一种对字母大小写敏感的脚本语句,即:Response.Write 是有效的,而response.write / ReSpoNSe.WRiTe 都是无效的语句。所以,各位朋友在书写时一定要特别注意。


Other Scripting Languages 其他脚本语言

ASP is shipped with VBScript and JScript (Microsoft's implementation of JavaScript). If you want to script in another language, like PERL, REXX, or Python, you will have to install script engines for them.
ASP直接支持VBScript脚本程序和JScript(微软公司自己的JavaScript脚本执行程序)脚本程序。如果你需要使用到其他语言,比如说:PERL,PEXX或者Python,那么你就必须安装这些脚本程序的驱动引擎。

Important: Because the scripts are executed on the server, the browser that displays the ASP file does not need to support scripting at all!
重要提示:因为脚本程序都是在服务器端执行的,所以浏览器不需要安装脚本程序就可以对ASP文件进行显示。

评论 (0) All

登陆 | 还没注册?