Script Tags and Delimiters

A script delimiter is a character or sequence of characters that marks the beginning or end of a unit. Delimiters differentiate HTML tags from text. In the case of HTML, these delimiters are the less than (<) and greater than (>) symbols (also known as angle brackets).

Similarly, delimiters differentiate ASP script commands and output expressions from both text and HTML tags. ASP uses the shorthand delimiters <% and %> to enclose script commands. For instance, the command

<% sport = "climbing" %> 

assigns the string "climbing" to the variable sport.

ASP also uses the delimiters <%= and %> to enclose output expressions. For instance, the output expression

<%= sport %>  

sends the current value of the variable to the browser.

You can include any valid primary scripting language expression within ASP delimiters. For instance, the following line produces text ending with the current server time:

This page was last refreshed at <%= Now %>. 

In this case, the Web server returns the value of the VBScript function Now to the browser along with the text.

The statements, expressions, commands, and procedures that are used within script delimiters must be valid for the default primary scripting language. ASP comes with the default primary scripting language set to VBScript. However, ASP lets you use other scripting languages. You can use the HTML script tags <SCRIPT> and </SCRIPT>, together with the Language and Runat attributes, to enclose complete procedures written in any language for which you have the scripting engine.

For instance, the following .asp file processes the JScript procedure MyFunction:

<HTML> <BODY> <% Call MyFunction %> </BODY> </HTML> <SCRIPT RUNAT=SERVER LANGUAGE=JAVASCRIPT>     function  MyFunction ()     {         Response.Write("MyFunction Called")     } </SCRIPT> 

Do not include any output expressions or script commands that are not part of complete procedures within <SCRIPT> tags.

You can include procedures written in your default primary scripting language within ASP delimiters.



Programming Microsoft Visual InterDev 6. 0
Programming Microsoft Visual InterDev 6.0
ISBN: 1572318147
EAN: 2147483647
Year: 2005
Pages: 143

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net