Latest web development tutorials

ASP CreateObject Method

Server Object Reference Complete Server Object Reference

CreateObject method creates an instance of an object.

Note: Objects created with this method there is a page scope.That is to say, after the current ASP page processing is complete, the server will automatically destroy these objects. To create a session or application scope there are objects, you can use the <object> tag in the Global.asa file and set the SCOPE session or application attributes, you can also store the object in session or application variable.

grammar

Server.CreateObject(progID)

参数 描述
progID 必需。要创建的对象的类型。


Example 1

This example creates an instance of the server component MSWC.AdRotator:

<%
Set adrot=Server.CreateObject("MSWC.AdRotator")
%>

Example 2

When the session ends, objects stored in the session variable is destroyed. However, you can also set the variable to Nothing new value or destroy the object:

<%
Session("ad")=Nothing
%>

或者:

<%
Session("ad")="a new value"
%>

Example 3

You can not create an object with the same name as the built-object instance. For example, the following script will return an error:

<%
Set Application=Server.CreateObject("Application")
%>


Server Object Reference Complete Server Object Reference