Although ASP is primarily used to create and process server-side scripts, it is possible to use it to generate client script that is processed by the client browser to extend its utility. You can write server-side scripts by combining script commands that are delivered to the browser.
This can be done by combining client script enclosed by HTML annotations and server-side scripts enclosed by delimiters:
SCRIPT language= "VBScript" >
!--
Client Script
% Server Script%>
Client Script
% Server Script%>
Client Script
...
-->
/script>
Using this feature of the scripting language, you can create exciting applications. For example, the following script will generate a subroutine of the client script that runs on the user's Web browser.
%
Servertime = time
Serverdate = Date
For i = 1 to 4
Randomize
greetcondition = Int (RND * 3)
%>
SCRIPT language= "VBScript" >
!--
Sub serveinfo<%= i%> ()
Select case<%= greetcondition%>
Case 0
MSG = "Hello," "%= servertime%>."
Case 1
MSG = "welcome! Today's date is%= serverdate%>.
Case 2
MSG = "Hi, the"%= servertime%> and the date is%= serverdate%>.
End Select
document.write MSG
End Sub
serveinfo<%= i%> ()
file://-->
/script>
%
Next
%>
In the above script, ASP retrieves time and date information on the server, and then loops through several cycles to generate subroutines that run on the user's Web server. Each client subroutine presents a random selection of greetings, displaying time and date information.
This script can be extended, for example, to retrieve and submit configuration information to a specified client script or component, such as an ActiveX control. The flexibility to use this scripting technique can also speed up WEB server processing and returning requests for user information.