ActiveX Components

As browser technology improved, additional platform dependence was introduced through ActiveX components, a technology based on Microsoft's Component Object Model (COM). ActiveX components range in style from fancy controls such as spinners and sliders to nonvisual components that allow data access or e-mail capability. These components make pages in Internet Explorer both attractive and functional but are nearly useless in environments that don't support ActiveX, such as Netscape Navigator.

An ActiveX component is added to a Web page through the <OBJECT> tag, which uniquely identifies the component to the browser. The following code uses an <OBJECT> tag to add an ActiveX label control to the Web page shown in Figure 1-4 on the following page:

<OBJECT ID="IeLabel3" WIDTH=148 HEIGHT=40     CLASSID="CLSID:99B42120-6EC7-11CF-A6C7-00AA00A47DD2"     CODEBASE="http://www.microsoft.com/activex/controls/ielabel.ocx">     <PARAM NAME="_ExtentX" VALUE="3916">     <PARAM NAME="_ExtentY" VALUE="1058">     <PARAM NAME="Caption" VALUE="Label3">     <PARAM NAME="Angle" VALUE="0">     <PARAM NAME="Alignment" VALUE="4">     <PARAM NAME="Mode" VALUE="1">     <PARAM NAME="FillStyle" VALUE="0">     <PARAM NAME="ForeColor" VALUE="#000000">     <PARAM NAME="BackColor" VALUE="#C0C0C0">     <PARAM NAME="FontName" VALUE="Arial">     <PARAM NAME="FontSize" VALUE="12">     <PARAM NAME="FontItalic" VALUE="0">     <PARAM NAME="FontBold" VALUE="0">     <PARAM NAME="FontUnderline" VALUE="0">     <PARAM NAME="FontStrikeout" VALUE="0">     <PARAM NAME="TopPoints" VALUE="0">     <PARAM NAME="BotPoints" VALUE="0"> </OBJECT> 

Figure 1-4. An ActiveX label control displayed on a Web page.

The <OBJECT> tag consists of several key parts that determine how an ActiveX component is displayed on the page. The ID attribute names the control. Once named, the control can be accessed through scripting code, and all the properties, events, and methods of the control are available to the page.

Perhaps the least understood attributes are CLSID and CODEBASE. CLSID is an alphanumeric serial number that uniquely represents an ActiveX component among all others. This serial number, known as a Globally Unique Identifier, or GUID, is not used by any other ActiveX component. Internet Explorer uses the GUID to locate the ActiveX component and create it in the page.

GUID numbers are tracked on any operating system through the registry, a centralized database that is responsible for maintaining information about software objects used by applications. When Internet Explorer encounters an <OBJECT> tag, it goes to the registry and matches the CLSID attribute with the GUID. When the GUID is located, the registry provides additional information that locates the file for the ActiveX control. Figure 15 shows one of the registry entries for the Calendar ActiveX control, as viewed with the Registry Editor.

Figure 1-5. Registry entry for the Calendar ActiveX control.

If the ActiveX control is not on the client machine, Internet Explorer uses the CODEBASE attribute to locate the ActiveX control on the server. The files for the control are downloaded via the CODEBASE attribute, and the ActiveX component is installed on the client machine. Once installed, Internet Explorer can use the control.

Accessing ActiveX components via the <OBJECT> tag is not restricted to controls. An <OBJECT> tag can activate any ActiveX component. This includes components you create with languages such as Visual Basic, J++, C++, and Microsoft FoxPro. In fact, you can easily extend the functionality afforded to the client by writing your own ActiveX components and downloading the components to the browser.

Supplying data to any component is accomplished with the <PARAM> tag. The <PARAM> tag uses the attributes NAME and VALUE to pass initial property value information to the ActiveX component when it is first created in the Web page. After the initial values are set, the properties can easily be changed at run time by using scripting calls.



Programming Active Server Pages
Programming Active Server Pages (Microsoft Programming Series)
ISBN: 1572317000
EAN: 2147483647
Year: 1996
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net