Introduction To The GLOBAL.ASA For ASP Programmers - Application and Session Objects
(Page 3 of 4 )
Moving along, the next thing we can do inside of the GLOBAL.ASA is object declarations. In other words, you can create a reference to an object with session or application scope to be used by any of the ASP pages in the application. This can be accomplished by utilizing the <object> tag.
When declaring an object, you need to follow a specific syntax, as follows:
<OBJECT id=id } |classid="classID" {progid="progID" scope="scope" runat="server"></OBJECT>
Follows are descriptions for each parameter:
• Scope – Sets the scope of the object. Can be either session or application.
• Id – A unique ID for the object.
• ProgID – The progID for your object, in the proper format.
• ClassID – The unique ID for the COM class object.
Note – Either a ProgID or a ClassID must be specified.
Here is an example of a GLOBAL.ASA with a declaration for the Microsoft Ad Rotator.
<SCRIPT language=vbscript runat="server">
Sub Application_OnStart
...
End Sub
Sub Application_OnEnd
...
End Sub
</SCRIPT>
<OBJECT id=AdObject progid="MSWC.AdRotator" scope="session" runat="server"></OBJECT>
You will notice that the <object> tag is outside of the <script> tag in the above example. This is the required format. To utilize the object in any ASP page, you would do the following:
This is an advertising page
<%=AdObject.GetAdvertisement("/myads.txt")%>
Next: Type libraries for COM >>
More ASP Articles
More By Rich Smith