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 we prefer to use.
VBScript
• VBScript is a scripting language
• A scripting language is a lightweight programming language
• VBScript is a light version of Microsoft’s programming language Visual Basic
When a VBScript is inserted into a HTML document, the Internet browser will read the HTML and interpret the VBScript. The VBScript can be executed immediately, or at a later event.
Scripts in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, other times when a user triggers an event.
Scripts to be executed when they are called or when an event is triggered go in the head section. When we place a script in the head section we will assure that the script is loaded before anyone uses it.
When we place a script in the body section it generates the content of the page.
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:
ASP is shipped with VBScript and JScript (Microsoft’s implementation of JavaScript). If we want to script in another language, like PERL, REXX, or Python, we need to install script engines for them. In ASP we can call a JavaScript procedure from a VBScript and vice versa.
When calling a VBScript or a JavaScript procedure from an ASP file written in VBScript, we can use the “call” keyword followed by the procedure name. If a procedure requires parameters, the parameter list must be enclosed in parentheses when using the “call” keyword. If we omit the “call” keyword, the parameter list must not be enclosed in parentheses. If the procedure has no parameters, the parentheses are optional.
When calling a JavaScript or a VB Script procedure from an ASP file written in JavaScript, always use parentheses after the procedure name.