Syntax
ASP Code in Examples
In all our examples, ASP code is shown in red, which helps you easily distinguish it from HTML. This visual separation makes it simpler to understand how ASP works on the server.
ASP Uses VBScript
The default scripting language used in ASP is VBScript.
A scripting language is a lightweight programming language designed for simple and fast execution. VBScript is a simplified version of Microsoft Visual Basic, making it easy to learn and use.
ASP Files
ASP files are similar to normal HTML files, but they also support server-side scripts.
ASP scripts are written between <% and %>
These scripts are executed on the server
The output generated by the script is sent to the browser as HTML
The Response.Write() method is used to display output on the web page.
Example:
<% Response.Write("Hello World!") %>
VBScript is case-insensitive, so Response.Write() and response.write() work the same way.
Using JavaScript in ASP
Although VBScript is the default language, you can also use JavaScript in ASP.
To use JavaScript, you must specify the scripting language at the top of the ASP page:
<%@ language="javascript"%>
<% Response.Write("Hello World!") %>However, this tutorial primarily uses VBScript for all examples.
More ASP Examples
ASP provides a shortcut for Response.Write(). You can simply use an equal sign (=) to output content.
Example:
<% ="Hello World!" %>
Using HTML in ASP Output
HTML tags can be included directly in ASP output to format content:
<% Response.Write("
You can use HTML tags to format the text!
") %>HTML attributes can also be used inside the output:
<% Response.Write("
This text is styled.
") %>