Basic ASP syntax

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.