ASP Basic syntax rules
In our ASP tutorial, every example provides hidden ASP source code. This makes it easier for you to understand how they work.
Write output to the browser
ASP files usually contain HTML tags, just like HTML files. However, ASP files can also contain server scripts, which are surrounded by delimiters <% and %>.
Server scriptsexecuted on the server, which can contain valid expressions, statements, procedures, or operators of the scripting language you choose.
response.write command
The response.write command is used to write output to the browser. The following example sends a piece of text to the browser: "Hello World":
Example
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
Try it Yourself »
There is also a shorthand method for the response.write command. The following example also sends a piece of text to the browser: "Hello World":
Example
<html>
<body>
<%
="Hello World!"
%>
</body>
</html>
Try it Yourself »
Using VBScript in ASP
You can use several scripting languages in ASP. However, the default scripting language is VBScript:
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
The example above writes the text "Hello World!" to the body part of the document.
Using JavaScript in ASP
If you need to set JavaScript as the default scripting language for a specific page, you must insert a line of language declaration at the top of the page:
<!DOCTYPE html>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>
Note:Unlike VBScript, JavaScript is case-sensitive! You must write your ASP code with different case letters according to the requirements of JavaScript.
Other scripting languages
ASP works natively with VBScript and JScript (JScript is Microsoft's implementation of JavaScript). If you want to write scripts in other languages, such as PERL, REXX, or Python, you must install the corresponding scripting engine.
More examples
Add some HTML tags to the text
Other extensions