Click to return to the Component Development home page    
Web Workshop  |  Component Development

So Happy Together? Using ActiveX Components with Active Server Pages


Nancy Winnick Cluts
Developer Technology Engineer
Microsoft Corporation

November 19, 1997

After writing several articles about Active Server Pages (ASP) technology, I've heard from lots of people who are clamoring for more information. One of the most-requested subjects is the use of ActiveX™ components from ASP. Where can you find information about available components? What tools help you build components? Where can you find samples for building components?

When deciding whether to use an ActiveX component in your server application, keep a few things in mind:

Once you decide that you are going to use an ActiveX server component, then decide whether you want to buy or to build the component yourself, and to what extent you can reuse the same code for other pages on your site.

The component can be written in any language: Visual Basic®, C++, Java, even FORTRAN! Any tool for any language that provides support for creating COM objects can be used to create an ActiveX component.

Reusing Components

Here in the soggy U.S. Pacific Northwest, recycling is very popular. Reuse of ActiveX server components fits well into this recycling life-style. The Internet Information Server (IIS) site offers many Active Server components you can download and use on your Web server. These components include the following:

Along with the components listed above, you can also access some developer samples Non-MSDN Online link. These samples not only demonstrate the use of ASP components, but are also implemented in five different environments: Microsoft Visual C++®, using the Microsoft Active Template Library (ATL); Microsoft Visual C++, using Microsoft Foundation Classes (MFC); Microsoft Visual J++™; Microsoft Visual Basic version 4.0; and Microsoft Visual Basic version 5.0. This means you don't have to send me e-mail asking for the Visual Basic version; it's already there. Finally, you can check out the ASP Components Catalog for more components.

Building ActiveX Server Components

Okay, let's say that these reusable components don't do exactly what you need, and you've not found a component you can buy that fits your needs. You may need to build your own. There are several environments you can use to build your ActiveX server components.

Who You Gonna Ask? Web Workshop

Once you decide what to build and which tool to use, you are probably going to look for specific tips for creating good server components. Luckily, our own MSDN Online Web Workshop already has articles that:

ActiveX Data Objects

ActiveX Data Objects Non-MSDN Online link (ADO) provide a collection of data access objects within an object library that enable you to write client applications that interact with databases. Those of you familiar with Data Access Objects (DAO) and Remote Data Objects (RDO) should find the programming model Non-MSDN Online link for ADO familiar. ActiveX server components can use ADO to work with databases to provide content based on user preferences, geographical data, or any other criterion.

You can use ADO on any operating system that supports COM and OLE automation (i.e.: 32-bit Windows environments). ADO is also language neutral: you can use it from C++, Java, Visual Basic, or any other language that supports COM and OLE automation.

To get started using ADO, check out the ADO Web site Non-MSDN Online link, and take a look there at an excerpt from the book Teach Yourself Active Web Database Programming in 21 Days Non-MSDN Online link. Reading it will give you a very good idea of just what ADO is and why it is so cool.

If you are going to use ADO, get familiar with the most commonly used ADO interfaces:

If you are already a proficient database developer, ADO shouldn't be difficult for you to use. It is well worth the time to learn about it if you are going to create a component that needs to interact with a database.

Still with Me?

If you've gotten this far, I can safely assume that you are still interested in writing ActiveX server components and using them with your ASP files. I encourage you to spend some time on the Microsoft IIS Web site Non-MSDN Online link to learn about ASP and the IIS environment. You can also check out the technical materials page Non-MSDN Online link on the Microsoft OLE DB site for further reading about databases and OLE (thrilling stuff ... really!).

Even as a little tyke, developer-technology writer Nancy Winnick Cluts was always the first one to raise her hand.


Get a grasp on ASP

Active Server Pages (ASP) technology provides a compile-free environment for creating server applications using any combination of HTML, scripting, and components. I've written several articles discussing the use of ASP, including an overview, tips, and general scripting. Others have written articles covering Web session management, creating ASP components, and debugging.

-- NWC

What is COM?

Component Object Model (COM) technology allows you to build applications from binary components that communicate together.

When you design an application to take advantage of COM, you pull out chunks of your code that stand alone in their functionality (for example, a specific set of functions that calculate a mortgage could go into a COM component).

These code chunks are implemented within executable (.exe) files or Dynamic Link Library (.dll) files. COM objects implemented in .dll files are called in-process servers, which can expose functions to outside applications. This means that other applications, even applications written by other companies, can call these exposed functions.

COM and ActiveX

ActiveX controls are implemented as COM objects. That's how ActiveX controls interoperate across networks, whether intranets or the Internet, and that's what allows the scripting of ActiveX controls.

When COM works across networks, it is called Distributed COM Non-MSDN Online link (DCOM). COM provides the aggregation (the way in which one object can make use of another object) for ActiveX. COM also provides the mechanism for packaging the parameters to functions (known as marshaling), so that those parameters can be passed across processes (and machines).

For technical how-to questions, check in with the Web Men Talking, the MSDN Online Web Workshop's answer pair.



Back to topBack to top

Did you find this material useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.