Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to wrap an ASP code as a component

Status
Not open for further replies.

eyal

Programmer
May 15, 2000
38
IL
Hi,<br>Anyone knows where can I find an information resource on how to wrape an ASP code as a component?<br>Thanks<br>Eyal
 
well you cant literally make it into a componet, but you can however throw some vbscript into a file, like say sub and functions, that you commonly use and name it with a *.inc extension, so at the top of your ASP you do<br><br>&lt;!--&lt;#include file mysubs.inc&gt;--&gt;<br><br>this will literally include that file into that sectino of the ASP, sort of the same as Cutting and PAsting that text into the ASP , so treat it as part of an ASP document, good thing about this method, is that it lets you include these sets of information onto any of your ASP just by including it, now if you want a conponet like an ActiveX dll, you need to use Visual Basic, or VC++(or any other programming language capable) to compile what you want to do into a dll. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Dear eyal and Karl,<br><br>Karl stated:<br><br>&gt; now if you want a conponet like an ActiveX dll, you need to use <br>&gt; Visual Basic, or VC++(or any other programming language capable) to compile <br>&gt; what you want to do into a dll. <br><br>That's not entirely accurate. You can actually make COM treat VBScript and JScript as an ActiveX control by building your code into a Windows Script Component compatible file. These files use XML to describe the component to COM etc. Check out the information on the MSDN CDROM or at MSDN Online at the following URL.<br><br><A HREF=" TARGET="_new"> luck<br>Pete
 
In IIS5 you can build a Specific ASP Page and use the server.execute method wich is very similar to an include file.<br><br>Did you know that you can build your own classes within your ASP Code?<br><br>Have a look at the following example:<br><br>Save the following page as ASPCODE.asp<br>&lt;%<br>Class aspcode<br>&nbsp;&nbsp;Private myNumber<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;Public Property Get MultiNum<br>&nbsp;&nbsp;&nbsp;&nbsp;MultiNum = myNumber<br>&nbsp;&nbsp;End Property<br><br>&nbsp;&nbsp;Public Property Let MultiNum(NewNum)<br>&nbsp;&nbsp;&nbsp;&nbsp;IF NewNum &gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myNumber = MultiNum<br>&nbsp;&nbsp;&nbsp;&nbsp;End if<br>&nbsp;&nbsp;End Property<br><br>&nbsp;&nbsp;Public Function Result()<br>&nbsp;&nbsp;&nbsp;&nbsp;Result = myNumber * 2<br>&nbsp;&nbsp;End Function<br><br>End Class<br>%&gt;<br><br>Now in your actual code you can do the following<br><br>&lt;%<br>Server.Execute AspCode.asp<br><br>Set obj = New AspCode<br>obj.MultiNum = 10&nbsp;&nbsp;'This is the Number you want to Multiply<br>Response.Write obj.Result&nbsp;&nbsp;'The result will now be 20<br>%&gt;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top