盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

怎么把ASP编写成DLL(2)

时间:2024/12/9作者:未知来源:盾怪网教程人气:

[摘要]现在,无论什么时候用户访问一个带有本组件的ASP文件,IIS就会把ScriptingContext传送给我们的对象请我们使用.这个ScriptingContext包括了全部的ASP方法和属性.实现上...
现在,无论什么时候用户访问一个带有本组件的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(2)




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版