ชุด Contents ของ ASP
ชุด Contents มีส่วนรวมของทั้งหมดที่เพิ่มเข้ามาด้วยคำสั่งสคริปต์สำหรับ application/session
คำแนะนำ:ในการลบโครงสร้างจากชุด Contents ใช้วิธี Remove และ RemoveAll
ศัพท์กรณ์
Application.Contents(Key) Session.Contents(Key)
ตัวแปร | รายละเอียด |
---|---|
key | สำคัญ。ชื่อของโครงสร้างที่ต้องการดึง |
สำหรับตัวแทนของ Application
ตัวอย่าง 1
โปรดระวังว่า name และ objtest จะถูกเพิ่มเข้าชุด Contents:
<% Application("name")="W3School" 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")="W3School" for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & "<br />") next %>
ออกแบบ:
date=2001/05/05 author=W3School
สำหรับตัวแทนของ 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