最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Asp组件中级入门与精通系列之五
时间:2008-01-18 编辑:简简单单 来源:一聚教程网
这里我们用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
-
上一个: 从asp到asp.net之快速转型
相关文章
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- asp中获取日期为星期几的技巧 09-14
- Asp编码优化参考 09-14
- .Net Core认证系统源码解析 12-26
- SharePoint Server 2019新特性介绍 01-15