加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

Contents 集合包含着通过脚本命令添加到 applicationsession 的所有项目

发布时间:2023-10-11 15:05:51 所属栏目:Asp教程 来源:
导读:Contents 集合包含着通过脚本命令添加到 application/session 的所有项目。

提示:要从 Contents 集合中删除项目,请使用 Remove 和 RemoveAll 方法。

语法

Application.Contents(Key)

Session.Cont
Contents 集合包含着通过脚本命令添加到 application/session 的所有项目。
 
提示:要从 Contents 集合中删除项目,请使用 Remove 和 RemoveAll 方法。
 
语法
 
Application.Contents(Key)
 
Session.Contents(Key)
 
参数 描述
 
key 必需。要取回的项目的名称。
 
针对 Application 对象的实例
 
实例 1
 
请注意,name 和 objtest 都会被追加到 Contents 集合中:
 
<%
 
Application("name")="verydoc"
 
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>")
 
Next
 
%>
 
实例 3
 
<%
 
Application("date")="2001/05/05"
 
Application("author")="verydoc"
 
for each x in Application.Contents
 
  Response.Write(x & "=" & Application.Contents(x) & "<br>")
 
next
 
%>
 
输出:
 
date=2001/05/05
 
author=verydoc
 
针对 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>")
 
Next
 
%>
 
实例 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
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章