asp组件问题. 我把代码写上,我想做一个加法容器的组件, 思路是这样的,通过index.asp中的text1,和text2提交到AS.ASP中.as.asp中只显示出text1+text2的值. 我把DLL的代码写出来,工程名字是huang,类的名字是demo. 代码如下 Private myapplication As Application Private myrequest As Request Private myresponse As Response Private myserver As Server Private mysession As Session 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 Public Sub onendpage() Set myscriptingcontext = Nothing Set myapplication = Nothing Set myrequest = Nothing Set myresponse = Nothing Set myserver = Nothing Set mysession = Nothing End Sub Public Sub welcomeinfo() Dim a, b, c b = myrequest.form1("text1") c = myrequest.form1("text2") a = b + c myresponse.Write ("a") End Sub index.asp代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <form id="form1" name="form" method="post" action="as.asp"> <p> <input type="text" name="text1" /> </p> <p> <label> <input type="text" name="text2" /> </label> </p> <p> <label> <input type="submit" name="h" value="加" /> </label> </p> </form> </body> </html> as.asp代码如下: <% Dim objSum Set objSum = Server.CreateObject("huang.demo") Result = objSum.welcomeinfo Response.Write Result Set objSum = Nothing %> 请哪个对ASP组件很了解的看看`` 到底程序到哪错误了
站长通常面临一个问题是,组件注册。 如果使用的是虚拟主机,根本没有权限去注册组件。 而且,程序能力大多就是够用,深入地开发,通常都不怎么能够胜任。 ASP 中的组件,更多的是 VB 吧(我也没接触过这个,具体不是太清楚)。而我们一般就是了解点脚本和数据库知识。
要把 DLL 写成一个 ActiveX 的 DLL 。有服务器注册后,可以用 Server.CreateObject 来建立。 一般是用 VB 来写这个 DLL 的。ASP 好象不行,不过网上有个 ASP2DLL 的工具,你可以试试(先说,我没用过)。 原理就是这样。但用的人不多,我想,因为大多数都没有注册组件的权限。而现在用的 ASP.net ,相比于 ASP ,就是组件不用注册了,放在指定的目录就可以了。与 J2EE 类似。