ASP Lesson 1:- Basics of ASP
(375 reads)
Syntax Rule for Basic ASP programming
In a ASP file it 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.
ASP Response Object
The Write method of the ASP Response Object is used to send content to the browser.
For example, the following statement sends the text "Hello World"
to the browser:
<%
response.write("Hello World!")
%>
Using VBScript
You may use different scripting languages in ASP files. However, the default
scripting language is VBScript:
<html>
<body>
<%
response.write("Hello World!")
%>
</body>
</html>
The example above writes "Hello World!" into the body of the document.
Using JavaScript
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("Hello World!")
%>
</body>
</html>
Please be Aware: Unlike VBScript - JavaScript is case sensitive.
You will have to write your ASP code with uppercase letters and lowercase letters
when the language requires it.
Using Lifetime of Variables
If variable declared outside a procedure can be accessed and changed by any
script in the ASP file.
If variable declared inside a procedure is created and destroyed every time
the procedure is executed. No scripts outside the procedure can access or change
the variable.
To declare variables accessible to more than one ASP file, declare them as
session variables or application variables.
Using Session Variables
Session variables are used to store information about ONE single user, and are
available to all pages in one application. Typically information stored in session
variables are name, id, and preferences.
Using Application Variables
Application variables are also available to all pages in one application. Application
variables are used to store information about ALL users in a specific application. |