ASP Basic Syntax Rules

« Previous Chapter Next Chapter »

In our ASP tutorial, every example shows the hidden ASP source code. This will make it easier for you to understand how it works.

Write Output to a Browser

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.

The response.write Command

The response.write command is used to write output to a browser. The Below example sends the text "Hai Everyone" to the browser:

Example

<html>
<body>
<%
response.write("Hai Everyone!")
%>

</body>
</html>

There is also a shorthand method for the response.write command. The Below example also sends the text "Hai Everyone" to the browser:

Example

<html>
<body>
<%
="Hai Everyone!"
%>

</body>
</html>


Using VBScript in ASP

You can use several scripting languages in ASP. However, the default scripting language is VBScript:

<html>
<body>
<%
response.write("Hai Everyone!")
%>
</body>
</html>

The example above writes "Hai Everyone!" into the body of the document.

Using JavaScript in ASP

To set JavaScript as the default scripting language for a particular page you must insert a language specification at the top of the page:

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

Note: JavaScript is case sensitive! You will have to write your ASP code with uppercase letters and lowercase letters when the language requires it.

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.


« Previous Chapter Next Chapter »

Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!