ASP Contents 集合
asp contents 集合

contents 集合包含著通過腳本命令添加到 application/session 的所有項目。
提示:要從 contents 集合中刪除項目,請使用 remove 和 removeall 方法。
語法
application.contents(key)
session.contents(key)
session.contents(key)
參數(shù) | 描述 |
---|---|
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

相關文章
- 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 方法