日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Asp组件中级入门与精通系列之五

發布時間:2023/12/9 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Asp组件中级入门与精通系列之五 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我們學習來看一下Response對象。其實我們前面的教程中一直都在使用這個對象的Write方法。

這里我們用Response對象設置cookie

?

打開vb6,新建Activex Dll工程。工程名修改為fCom,類名修改為fZ5
引用“Microsoft Active Server Pages Object”對象庫。
創建兩個組件事件:OnStartPage以及OnEndPage
在事件OnStartPage中創建類ScriptingContent的一個引用。
實例化類ScriptingContent

?

代碼如下:

Option Explicit

'對象的聲明

Dim myResponse As Response

Dim myRequest As Request

Dim myApplication As Application

Dim myServer As Server

Dim mySession As Session

?

??? '當組件被創建的時候會觸發這個事件

Public Sub OnStartPage(myScriptingContent As ScriptingContext)

???? '進行對象的實例化

???? Set myResponse = myScriptingContent.Response

???? Set myRequest = myScriptingContent.Request

???? Set myServer = myScriptingContent.Server

???? Set myApplication = myScriptingContent.Application

???? Set mySession = myScriptingContent.Session

End Sub

?

??? '當組件被銷毀的時候觸發這個事件

Public Sub OnEndPage()

???? '銷毀對象

???? Set myResponse = Nothing

???? Set myRequest = Nothing

???? Set myServer = Nothing

???? Set myApplication = Nothing

???? Set mySession = Nothing

End Sub

?

'從頁面中設置Cookie,組件中得到

Public Sub GetCookie()

??? Dim myitem

??? '全部信息

??? For Each myitem In myRequest.Cookies

??????? myResponse.Write myitem & ": " & myRequest.Cookies.Item(myitem)

??????? myResponse.Write "
"

??? Next

???

??? '單個信息

??? myResponse.Write "其中用戶姓名是" & ": " & myRequest.Cookies("username")

??? myResponse.Write "
"

??? myResponse.Write "其中用戶年齡是" & ": " & myRequest.Cookies("age")

??? myResponse.Write "
"

End Sub

'組件中設置cookie,頁面中得到

Public Sub SetCookie()

??? myResponse.Cookies("com_username") = "龍卷風"

??? myResponse.Cookies("com_age") = 26

??? myResponse.Expires = #9/13/2004#

End Sub

?

編譯成Dll文件,系統自動會注冊。

否則就手工注冊 Regsvr32 f:"test"fcom.dll

?

測試

打開visual interdev6.0,生成一個fz5.asp文件

dim obj

set obj=server.CreateObject ("fcom.fz5")

call obj.setcookie()

Response.Write Request.Cookies("com_username")

Response.Write "
"

Response.Write Request.Cookies("com_age")???

Response.Write "
"

?

'下面在頁面中設置Cookie

Response.Cookies("username") = "龍卷風"

Response.Cookies("age") = 26

call obj.GetCookie()

?

%>

?

配置好虛擬目錄,在ie中執行fc5.asp文件,可以看到

龍卷風
26
age: 26
username: 龍卷風
com_age: 26
com_username: 龍卷風
其中用戶姓名是: 龍卷風
其中用戶年齡是: 26

未完待續

轉載于:https://www.cnblogs.com/Athrun/archive/2008/03/28/1127660.html

總結

以上是生活随笔為你收集整理的Asp组件中级入门与精通系列之五的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。