Koleksi Contents ASP

Panduan Referensi Objek Application

Koleksi Contents mengandung semua proyek yang ditambahkan ke application/session melalui perintah skrip.

Petunjuk:Untuk menghapus proyek dari koleksi Contents, gunakan metode Remove dan RemoveAll.

Syarat

Application.Contents(Key)
Session.Contents(Key)
Parameter Deskripsi
key Wajib. Nama proyek yang akan diambil.

Untuk instansi objek Application

Contoh 1

Perhatikan, name dan objtest akan ditambahkan ke koleksi Contents:

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

Contoh 2

Mengelilingi koleksi Contents:

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

atau:

<%
For i=1 to Application.Contents.Count
  Response.Write(i & "=" & Application.Contents(i) & "<br />")
Next
%>

Contoh 3

<%
Application("date")="2001/05/05"
Application("author")="W3School"
for each x in Application.Contents
  Response.Write(x & "=" & Application.Contents(x) & "<br />")
next
%>

Output:

date=2001/05/05
author=W3School

Untuk instansi objek Session

Contoh 1

Perhatikan, name dan objtest akan ditambahkan ke koleksi Contents:

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

Contoh 2

Mengelilingi koleksi Contents:

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

atau:

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

Output:

name=Hege
date=2001/05/05

Panduan Referensi Objek Application