<% 'look for a command sent from the FORM section buttons
If Len(Request.Form("cmdAdd")) Then ' 使用是不是长度为0来判别
strVarName = Request.Form("txtVarName")
strVarValue = Request.Form("txtVarValue")
Application.Lock
Application(strVarName) = strVarValue ' 此处报错
Application.Unlock
End If
If Len(Request.Form("cmdRemoveThis")) Then
strToRemove = Request.Form("lstRemove")
Application.Lock
Application.Contents.Remove(strToRemove)
Application.Unlock
End If
If Len(Request.Form("cmdRemoveAll")) Then
Application.Lock
Application.Contents.RemoveAll
Application.Unlock
End If
%>
<P><DIV CLASS="subhead">The Application.Contents Collection</DIV>
<%
For Each objItem in Application.Contents
If IsObject(Application.Contents(objItem)) Then
Response.Write "Object reference: '" & objItem & "'<BR>"
ElseIf IsArray(Application.Contents(objItem)) Then
Response.Write "Array: '" & objItem & "' contents are:<BR>"
varArray = Application.Contents(objItem)
'note: the following only works with a one-dimensional array
For intLoop = 0 To UBound(varArray)
Response.Write " Index(" & intLoop & ") = " & varArray(intLoop) & "<BR>"
Next
Else
Response.Write "Variable: '" & objItem & "' = " _
& Application.Contents(objItem) & "<BR>"
End If
Next
%>
<P><DIV CLASS="subhead">The Application.StaticObjects Collection</DIV>
<%
For Each objItem in Application.StaticObjects
If IsObject(Application.StaticObjects(objItem)) Then
Response.Write "<OBJECT> element: ID='" & objItem & "'<BR>"
End if
Next
%>
<!-- collect values to execute Application methods with -->
<FORM ACTION="<% = Request.ServerVariables("SCRIPT_NAME") %>" METHOD="POST"> ' 使用Request.ServerVariables("SCRIPT_NAME")将表单提交给本身
<P><DIV CLASS="subhead">Add a value to the Application Object</DIV>
<INPUT TYPE="SUBMIT" NAME="cmdAdd" VALUE=" ">
Application("
<INPUT TYPE="TEXT" NAME="txtVarName" SIZE="15" VALUE="My_New_Value">
") = "
<INPUT TYPE="TEXT" NAME="txtVarValue" SIZE="20" VALUE="Testing, testing ...">
"<P>
<P><DIV CLASS="subhead">Remove a value from the Application Object</DIV>
<INPUT TYPE="SUBMIT" NAME="cmdRemoveThis" VALUE=" ">
Application.Contents.Remove("
<SELECT NAME="lstRemove" SIZE="1">
<%
For Each objItem in Application.Contents
Response.Write "<OPTION>" & objItem & "</OPTION>"
Next
%>
</SELECT>")<BR>
<INPUT TYPE="SUBMIT" NAME="cmdRemoveAll" VALUE=" ">
Application.Contents.RemoveAll