Library tutorials & articles
Using Components and Objects in ASP
- Introduction
- Advantages
- Using Objects
- Creating COM components
- Using Built-in ASP objects
- Creating objects from a java class
Creating COM components
ASP supports Windows Script Components, Microsoft's powerful scripting technology that you can use to create COM components. Specifically, you can encapsulate common scripts, such as those used for database access or content generation, into reusable components accessible from any .asp file or program. You can create Windows Script Components by writing scripts in a language such as VBScript or JScript without a special development tool. You can also incorporate Windows Script Components into programs written in COM compliant programming languages, such as Visual Basic, C++, or Java. The following is an example of a Windows Script Components, written in VBScript, that defines methods for converting temperature measurements between Fahrenheit and Celsius:
<SCRIPTLET>
<Registration
Description="ConvertTemp"
ProgID="ConvertTemp.Scriptlet"
Version="1.00"
>
</Registration>
<implements id=Automation type=Automation>
<method name=Celsius>
<PARAMETER name=F/>
</method>
<method name=Fahrenheit>
<PARAMETER name=C/>
</method>
</implements>
<SCRIPT LANGUAGE=VBScript>
Function Celsius(F)
Celsius = 5/9 * (F - 32)
End Function
Function Fahrenheit(C)
Fahrenheit = (9/5 * C) + 32
End Function
</SCRIPT>
</SCRIPTLET>
Before implementing this Windows Script Component you must save this file with an .sct extension and then in Windows Explorer, right-click this file and select Register. To use this Windows Script Component in a Web page, you would use a server-side script such as the following:
<%
Option Explicit
Dim objConvert
Dim sngFvalue, sngCvalue
sngFvalue = 50
sngCvalue = 21
Set objConvert = Server.CreateObject("ConvertTemp.Scriptlet")
Response.Write sngFvalue & " degrees Fahrenheit is equivalent to "
& objConvert.Celsius(sngFvalue) & " degrees Celsius<br>"
& vbNewLine
Response.Write sngCvalue & " degrees Celsius is equivalent to "
& objConvert.Fahrenheit(sngCvalue) & " degrees Fahrenheit<br>"
& vbNewLine
%>
Related articles
Related discussion
-
Read eMails from Outlook express using ASP
by kumaravelu (1 replies)
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Variable In Vb.Net
by chia (0 replies)
-
ideas in building a captive portal
by sjranjan (2 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
If you want to try using components, start using those allready installed on your server. Use this script to check your IIS for installed components:
http://www.bier-voting.de/objcheck/
This thread is for discussions of Using Components and Objects in ASP.