Penghimpunan Contents ASP

Panduan Rujukan Objek Aplikasi

Penghimpunan Contents mengandung semua projek yang ditambahkan ke application/session melalui perintah skrip.

Petunjuk:Untuk menghapus projek dari penghimpunan Contents, gunakan metode Remove dan RemoveAll.

Sintaks

Application.Contents(Key)
Session.Contents(Key)
Parameter Deskripsi
kunci Diperlukan. Nama projek yang akan diambil kembali.

Untuk contoh objek Application

Contoh 1

Perhatian, name dan objtest akan ditambahkan ke penghimpunan Contents:

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

Contoh 2

Mengalami penghimpunan 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
pengarang=W3School

Untuk contoh objek Session

Contoh 1

Perhatian, name dan objtest akan ditambahkan ke penghimpunan Contents:

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

Contoh 2

Mengalami penghimpunan 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 Rujukan Objek Aplikasi