ASP Contents 集合
asp contents 集合
完整的 application 对象参考手册contents 集合包含着通过脚本命令添加到 application/session 的所有项目。
提示:要从 contents 集合中删除项目,请使用 remove 和 removeall 方法。
语法
application.contents(key)
session.contents(key)
session.contents(key)
参数 | 描述 |
---|---|
key | 必需。要取回的项目的名称。 |
针对 application 对象的实例
实例 1
请注意,name 和 objtest 都会被追加到 contents 集合中:
<%
application("name")="runoob"
set application("objtest")=server.createobject("adodb.connection")
%>
application("name")="runoob"
set application("objtest")=server.createobject("adodb.connection")
%>
实例 2
遍历 contents 集合:
<%
for each x in application.contents
response.write(x & "=" & application.contents(x) & "
")
next
%>
或者:
<%
for i=1 to application.contents.count
response.write(i & "=" & application.contents(i) & "
")
next
%>
for each x in application.contents
response.write(x & "=" & application.contents(x) & "
")
next
%>
或者:
<%
for i=1 to application.contents.count
response.write(i & "=" & application.contents(i) & "
")
next
%>
实例 3
<%
application("date")="2001/05/05"
application("author")="runoob"
for each x in application.contents
response.write(x & "=" & application.contents(x) & "
")
next
%>
输出:
date=2001/05/05
author=runoob
application("date")="2001/05/05"
application("author")="runoob"
for each x in application.contents
response.write(x & "=" & application.contents(x) & "
")
next
%>
输出:
date=2001/05/05
author=runoob
针对 session 对象的实例
实例 1
请注意,name 和 objtest 都会被追加到 contents 集合中:
<%
session("name")="hege"
set session("objtest")=server.createobject("adodb.connection")
%>
session("name")="hege"
set session("objtest")=server.createobject("adodb.connection")
%>
实例 2
遍历 contents 集合:
<%
for each x in session.contents
response.write(x & "=" & session.contents(x) & "
")
next
%>
或者:
<%
for i=1 to session.contents.count
response.write(i & "=" & session.contents(i) & "
")
next
%>
for each x in session.contents
response.write(x & "=" & session.contents(x) & "
")
next
%>
或者:
<%
for i=1 to session.contents.count
response.write(i & "=" & session.contents(i) & "
")
next
%>
实例 3
<%
session("name")="hege"
session("date")="2001/05/05"
for each x in session.contents
response.write(x & "=" & session.contents(x) & "
")
next
%>
输出:
name=hege
date=2001/05/05
session("name")="hege"
session("date")="2001/05/05"
for each x in session.contents
response.write(x & "=" & session.contents(x) & "
")
next
%>
输出:
name=hege
date=2001/05/05
完整的 application 对象参考手册
相关文章
- ASP Global.asa
- ASP Browser Capabilities
- ASP – AJAX 与 ASP
- ASP Line 属性
- ASP Read 方法
- ASP ReadAll 方法
- ASP Attributes 属性
- ASP Delete 方法
- ASP Key 属性
- ASP CacheControl 属性
- ASP IsClientConnected 属性
- ASP Clear 方法
- ASP Flush 方法
- ASP Contents 集合
- ASP Contents.Remove 方法
- ASP GetLastError 方法
- ASP Drives 属性
- ASP CopyFile 方法
- ASP CopyFolder 方法
- ASP FileExists 方法