An ASP file is very similar to a common HTML file and contains HTML tags. However, ASP files also contain server-side scripts ).
In the ASP file, <% indicates the start of the server script, and %> indicates the end of the server script. For example, define and output a variable in ASP:
<%
Dim vname
Vname = "www.webyi.com"
%>
ASP output syntax
In the ASP file, use response. Write to display the output result. See the following sample code:
<HTML>
<Head>
<Title> Asp output Syntax: Use response. Write </title>
</Head>
<Body>
<%
Response. Write ("www.webyi.com ")
%>
</Body>
</Html>
The following ASP code example demonstrates how to output text in HTML format.
<% Response. Write ("<H2> webmaster library </H2>") %>
<% Response. Write ("<P style = 'color: red'> www.webjx.com/html </P>") %>
In addition to response. Write, you can also use another shorthand to indicate the output, that is, <% =. See the following sample code:
<% = "Www.webyi.com" %>
ASP scripting language settings
The default scripting language of ASP is VBScript. VBScript is the most appropriate scripting language for compiling ASP.
In addition to VBScript, you can also use other scripting languages to compile ASP Web pages.
In ASP Web pages, you can set the scripting language used by ASP Web pages. The sample code is as follows:
<% @ Language = "JavaScript" %>
<HTML>
<Head>
<Title> set the sample code of the scripting language used by ASP </title>
</Head>
<Body>
<%
VaR d = new date ()
Response. Write (d)
%>
</Body>
</Html>
<% @ Language = "JavaScript" %> the Code indicates that the script language used for the ASP file is JavaScript. This code must begin with an ASP file.
Because VBScript is the default scripting language of ASP, it does not matter if you do not write <% @ Language = "VBScript" %> in the ASP file, ASP automatically processes the scripts between <%> as VBScript.
Note: VBScript is case-insensitive, but Javascript is case-sensitive. For example, in VBScript, you can use response. Write in lower case, and the script will run normally. But it does not work in Javascript. You must write Response. Write; otherwise, an error will occur.