最新的Web開發教程
 

ASP Contents.Remove方法


<完整的會話對象參考

該Contents.Remove方法刪除從內容集合的項目。

句法

Application.Contents.Remove(name|index)

Session.Contents.Remove(name|index)

參數 描述
name 該項目的名稱以去除
index 該項目的索引中刪除

應用程序對象實例

實施例1

<%
Application("test1")=("First test")
Application("test2")=("Second test")
Application("test3")=("Third test")

Application.Contents.Remove("test2")

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

Output:

test1=First test
test3=Third test

實施例2

<%
Application("test1")=("First test")
Application("test2")=("Second test")
Application("test3")=("Third test")

Application.Contents.Remove(2)

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

Output:

test1=First test
test3=Third test

對於Session對象實例

實施例1

<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")

Session.Contents.Remove("test2")

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

Output:

test1=First test
test3=Third test

實施例2

<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")

Session.Contents.Remove(2)

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

Output:

test1=First test
test3=Third test

<完整的會話對象參考