Latest web development tutorials

ASP Sommaire collection

Application Object Reference Complete Application Object Reference

collection Contents contient un script pour ajouter des commandes à l'application / session pour tous les projets.

Conseil: Pour supprimer un élément de la collection Contents, utilisez la méthode Remove et RemoveAll.

grammaire

Application.Contents(Key)

Session.Contents(Key)

参数 描述
key 必需。要取回的项目的名称。


Par exemple objet Application

exemple 1

S'il vous plaît noter, le nom et objtest sera ajouté à la collection Contents:

<%
Application("name")="W3CSchool"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%>

exemple 2

collection Contents traversal:

<%
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
%>

exemple 3

<%
Application("date")="2001/05/05"
Application("author")="W3CSchool"

for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x) & "<br>")
next
%>

输出:

date=2001/05/05
author=W3CSchool


Par exemple objet Session

exemple 1

S'il vous plaît noter, le nom et objtest sera ajouté à la collection Contents:

<%
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>

exemple 2

collection Contents traversal:

<%
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
%>

exemple 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 Object Reference Complete Application Object Reference