ASP 內容 集合
❮ 完整的 Application 物件參考
Contents 集合包含透過指令碼命令附加到 application/session 的所有項。
提示: 要從 Contents 集合中刪除項,請使用 Remove 和 RemoveAll 方法。
語法
Application.Contents(Key)
Session.Contents(Key)
引數 | 描述 |
---|---|
key | 必需。要檢索的項的名稱 |
Application 物件的示例
示例 1
注意 name 和 objtest 都會被附加到 Contents 集合中
<%
Application("name")="W3Schools"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%>
示例 2
遍歷 Contents 集合
<%
for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x) & "<br>")
next
%>
或
<%
For i=1 to Application.Contents.Count
Response.Write(i & "=" & Application.Contents(i) & "<br>")
下一步
%>
示例 3
<%
Application("date")="2001/05/05"
Application("author")="W3Schools"
for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x) & "<br>")
next
%>
輸出
date=2001/05/05
author=W3Schools
Session 物件的示例
示例 1
注意 name 和 objtest 都會被附加到 Contents 集合中
<%
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>
示例 2
遍歷 Contents 集合
<%
for each x in Session.Contents
Response.Write(x & "=" & Session.Contents(x) & "<br>")
next
%>
或
<%
For i=1 to Session.Contents.Count
Response.Write(i & "=" & Session.Contents(i) & "<br>")
下一步
%>
示例 3
<%
Session("name")="Hege"
Session("date")="2001/05/05"
for each x in Session.Contents
Response.Write(x & "=" & Session.Contents(x) & "<br>")
next
%>
輸出
name=Hege
date=2001/05/05
❮ 完整的 Application 物件參考