Koleksi Isi ASP
Sesi lengkap Referensi Obyek
Koleksi isinya berisi script untuk menambahkan perintah ke aplikasi / sesi untuk semua proyek.
Tip: Untuk menghapus item dari koleksi Isi, menggunakan metode Hapus dan removeAll.
tatabahasa
Application.Contents(Key)
Session.Contents(Key)
Session.Contents(Key)
参数 | 描述 |
---|---|
key | 必需。要取回的项目的名称。 |
Misalnya Aplikasi Object
contoh 1
Harap dicatat, nama dan objtest akan ditambahkan ke koleksi Isi:
<%
Application("name")="W3CSchool"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%>
Application("name")="W3CSchool"
Set Application("objtest")=Server.CreateObject("ADODB.Connection")
%>
contoh 2
Koleksi Isi 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
%>
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
%>
contoh 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
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
Misalnya Sesi objek
contoh 1
Harap dicatat, nama dan objtest akan ditambahkan ke koleksi Isi:
<%
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>
contoh 2
Koleksi Isi 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
%>
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
%>
contoh 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
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
Sesi lengkap Referensi Obyek