动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 如何把ASP编写成DLL(2)

作者:风未起时 来源:中国站长学院 
阅读 2832 人次 , 2006-2-15 14:17:00 

现在,无论什么时候用户访问一个带有本组件的ASP文件,IIS就会把ScriptingContext传送给我们的对象请我们使用.这个ScriptingContext包括了全部的ASP方法和属性.实现上,这使得我们有能力访问所有ASP的对象.看下面的代码:

Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set MyScriptingContext = PassedScriptingContext
Set MyApplication = MyScriptingContext.Application
Set MyRequest = MyScriptingContext.Request
Set MyResponse = MyScriptingContext.Response
Set MyServer = MyScriptingContext.Server
Set MySession = MyScriptingContext.Session
End Sub

以后我们就能用在VB中用MyApplication 来代替ASP中的Application,同理可以代替Request,Server.....,不过我们来是要在 OnStartPage之前来申明这些变量:

Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session

使用ASP的对象
我们的变量现在就能像标准的ASP对象来使用了!比如,我们经常在ASP中用Request.form()来收集提交表单的数据.现在我们在我们的VB中实现这个功能,代码如下:

用ASP中实现:
〈%
MyTempVariable = Request.Form("userName")
Response.Write ("you entered "& MyTempVariable & "as your user name")
%>

在VB中实现:

MyTempVariable = MyRequest.Form("userName")
MyResponse.Write ("you entered "& MyTempVariable & "as your user name")

通过使用MyResponse来代替Response,我们能够使用所有Response的方法,当然,MyResponse这个名字可以随便来取,你甚至可以就取Response.
另一件我们得注意   
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:如何把ASP编写成DLL(1)
· 下一篇:如何把ASP编写成DLL(3)
· remote script文档(转载自微软)(四)
· 纯ASP上传图像文件到数据库的最佳例子
· 用Asp隐藏文件路径,实现防盗链
· 不用图像组件的ASP图像计数器
· len(),lift(),right()不能正常识别中文的解决方法


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077