Option Explicit
Dim m blnIsBold As Boolean
Public Property Let IsBold (ByVal tmpBold as Boolean)
m_blnIsBold = tmpBold
End Property
Public Property Get IsBold() As Boolean
IsBold = m_lnIsBold
End Property
Public Sub WebOutput (Response As Object, strWebOutput As String)
If m_blnIsBold Then
Response.Write "Bold was selected. Here is the string:<br>"
Response.Write "<b>" & strWebOutput & "</b><br>"
Else
Response.Write "Bold was not selected. Here is the string:<br>"
Response.Write strWebOutput
End If
End Sub
Figure 11 Default.asp
<%@ Language=VBScript %>
<% 'c:\vbtest\default.asp%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
strGreeting="Hello, Our object worked!"
Set objGreetings = Server.CreateObject ("Greetings.SayHello")
objGreetings.IsBold = True
Response.Write "The value of IsBold is: " & objGreetings.IsBold & "<br>"
objGreetings.WebOutput Response, CStr(strGreeting)
Set objGreetings = nothing
%>
</BODY>
</HTML>
Figure 13 ADSI.asp
<%@ Language=VBScript %>
<%
Dim Action
Dim strRootPath
Dim DirObject
Action = Request.QueryString("Action")
If Action <> "" Then
strRootPath = "IIS://myservername/W3SVC/4/ROOT"
Set DirObject = GetObject (strRootPath)
End If
If Action = "Create" Then
DirObject.AppCreate False
DirObject.AppFriendlyName = "Friendly Name"
DirObject.SetInfo
End If
If Action = "Remove" Or Action = "RemoveCreate" Then
DirObject.AppCreate True
If Action = "RemoveCreate" Then Response.Redirect "ADSI.asp?Action=Create"
End If
%>
<HTML>
<BODY>
<CENTER>
<%
If Action <> "" Then
Response.write "Action Complete<br>"
End If
%>
<FORM METHOD="GET" ACTION="ADSI.asp">
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="Create">
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="Remove">
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="RemoveCreate">
</FORM>
</CENTER>
</BODY>
</HTML>
Figure 14 Using Object Context
Option Explicit
Dim m blnIsBold As Boolean
Public Property Let IsBold (ByVal tmpBold As Boolean)
m_blnIsBold = tmpBold
End Property
Public Property Get IsBold() As Boolean
IsBold = m_blnIsBold
End Property
' ================================================
' Notice we don't have to pass the Response object
' ================================================
Public Sub WebOutput (strWebOutput As String)
Dim objContext As ObjectContext
Dim objResponse As Object
Set objContext = GetObjectContext
Set objResponse = objContext.Item ("Response")
" = = =Could Add More intrinsic ASP objects here= = =
If m_blnIsBold Then
objResponse.Write "Bold was selected. Here is the string:<br>"
objResponse.Write "<b>" & strWebOutput & "</b><br>"
Else
objResponse.Write "Bold was not selected. Here is the string:<br>"
objResponse.Write strWebOutput
End If
End Sub
Figure 16 Calling Web Output
<%@ Language=VBScript %>
<% 'c:\vbtest\default.asp%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
strGreeting="Hello, Our object worked!"
Set objGreetings = Server.CreateObject ("Greetings.SayHello")
objGreetings.IsBold = True
Response.Write "The value of IsBold is: " & objGreetings.IsBold & "<br>"
'===Notice we do not pass the Response object===
objGreetings.WebOutput CStr(strGreeting)
Set objGreetings = nothing
%>
</BODY>
</HTML>