Special Edition Using Microsoft® Visual Studio for Enterprise Development

Previous chapterNext chapterContents


- 14 -
Developing Active Content with Visual InterDev

by Azam A. Mirza

Learn about the IDE used by Visual InterDev and how it is used to create workspaces, projects, and files for developing a web site.
Learn about using the wizards to create projects and files. Get an understanding of the various wizards and how they can help you get a jump on web application development.
Learn about the content creation tools supplied with Visual InterDev, including the Visual InterDev source editor and FrontPage 97 HTML editor.
Learn about creating, using, understanding, and distributing ActiveX server components. Learn about the server components supplied with Visual InterDev.
Learn about using client-side ActiveX components and Java applets in your web sites.

Microsoft Visual InterDev is a next-generation development tool designed for building dynamic web applications and enterprisewide Internet and intranet web sites. Until recently, web development was predominantly a matter of writing static HTML pages for viewing through a browser; however, the popularity of the web has created a need for building web sites and applications that can deliver dynamic and user-specific content.

Visual InterDev leverages the power of two of Microsoft's key Internet technologies to deliver an environment for building dynamic web sites. It uses the Microsoft Internet Information Server (IIS) as an integral back-end web server for hosting web sites. In addition, it uses Active Server Pages (ASP) technology for delivering dynamic web pages to client browsers.


 See Chapter 13, "An Inside Look at Active Server Pages and Internet Information Server."

The HTML- and HTTP-based nature of the web makes traditional client/server tools less useful for building web applications. In addition, the HTML interface is not a mature environment and lacks many of the GUI features taken for granted when doing client/server development. For example, the standards supported by the various browsers differ widely, with some browsers supporting only Java and others supporting both Java and ActiveX.


NOTE: Netscape Navigator doesn't include native support for displaying ActiveX controls. However, you can access web sites that use ActiveX controls by downloading the ActiveX plug-in for Netscape, called ScriptActive from NCompass Labs for Windows 95 and Windows NT, from the NCompass Labs web site (http://www.ncompasslabs.com/).

A critical component of dynamic web application development is database connectivity. A truly dynamic web site is invariably dependent on a back-end database to provide the content. The web environment presents interesting twists and challenges to maintaining database connections and providing users access to pertinent data.

Microsoft Visual InterDev was designed to address these issues and various others when tackling web application development. It provides a mating of traditional client/server development methodologies, tools with web-based technologies, and tools for building robust web applications. The following sections discuss in detail the Visual InterDev development environment and how you can use it to build great dynamic web sites.


NOTE: To use Visual InterDev, you must be using Microsoft Internet Information Server with Active Server Pages and the Microsoft FrontPage Server Extensions. Visual InterDev needs FrontPage Server Extensions to communicate with the web server.

Visual InterDev Integrated Development Environment

Microsoft Visual InterDev uses the Microsoft Developer Studio as its Integrated Development Environment (IDE). Developer Studio is the IDE used by two other products included as part of Visual Studio 97--Visual C++ and Visual J++.

Users familiar with either Visual C++ or Visual J++ will feel instantly at ease with the Visual InterDev IDE. Developer Studio is a very user-friendly and highly productive IDE that serves as a kind of "one-stop shop" for all development-process tasks.


See Chapter 2, "Using Visual Studio to Create Applications."

When using the Developer Studio IDE for building web applications, the developer is actually working against a live web site. During development, the parts of the web site being modified are copied to the local developer workstation. When the developer has finished making modifications, Visual InterDev automatically uploads the latest versions of the modified files to the web server.


NOTE: Typically, developers work against a web server that acts as the staging server for Visual InterDev development. A staging server is analogous to a development machine that is used to develop, debug, and test web sites before moving the content to a production server. As content is developed, it can be uploaded to the staging web server and debugged for errors during the development process.

After a web site has been fully developed and debugged, it can be moved to the production server for use. Visual InterDev provides a simple and powerful mechanism for moving a web site from the development stage to the production stage.


TIP: Visual InterDev includes a unique and powerful mechanism for graphically displaying the topology of a web site, called the Link View. From the Tools menu, select View Links on WWW and provide the URL of a web site to explore its topology.


See "Link Repair and Link View," Chapter 15

The following sections highlight the key features of Visual InterDev that are used to build powerful, dynamic, database-enabled web applications and sites.

Working with Workspaces

When working within the Visual InterDev IDE, developers work in the context of a workspace. A workspace is the hosting place for various Visual InterDev, Visual C++, and Visual J++ projects. A developer can have any number of projects open within a workspace, depending on the amount of memory available on the machine.


TIP: The Developer Studio IDE can host Visual C++, Visual J++, and Visual InterDev projects within the same workspace, thus enabling developers to work on an ActiveX control in Visual C++ or a Java applet in Visual J++ at the same time as they work on a web site in Visual InterDev. The developers can develop the components and test them on the web site from within a single IDE.

To create a workspace in Visual InterDev, perform the following steps:

1. Select New from the File menu. The New dialog box appears.

2. Click the Workspaces tab and select the Blank Workspace option.

3. Enter a name for the workspace you are creating. The Location box automatically updates to display the location where the workspace will be created. By default, Visual InterDev stores all workspaces in the directory <root>\Program Files\DevStudio\MyProjects on the local workstation and in the \inetpub\wwwroot\ directory on the server.


CAUTION: Make sure the workspace name you provide is unique because the system will attempt to create a directory with that name in the default location for creating Visual InterDev projects. Alternatively, you can provide a different location for creating the workspace.
4. Click OK to create the new workspace. The Visual InterDev IDE updates to display the newly created workspace with no projects attached.

The next section outlines the procedures for creating web projects within Visual InterDev.

Creating Projects

The first step in creating a web site is to create the project that will host the web site. A workspace within Visual InterDev IDE hosts the project. You can have multiple projects within a workspace; however, only one project can be the active project at any given time.

To create a web project, follow these steps:

1. Select New from the File menu. The New dialog box is displayed.

2. Click the Projects tab to display the various project options that can be selected, as shown in Figure 14.1.

FIG. 14.1
Visual InterDev enables you to create projects by using the project wizards.


NOTE: Because Visual C++ and Visual J++ share the Visual InterDev IDE, the New dialog box also displays possible choices for the other two environments. Select the appropriate choice from the displayed list.
3. Select the project type you want to create. For creating web sites, you can choose the Web Project Wizard or the Departmental Site Wizard.


NOTE: The Web Project Wizard enables you to generate a skeleton web site that you can work from. The Departmental Site Wizard is geared towards creating a sample departmental site for use within corporate intranets.
4. Provide a name for your project. The location box is updated automatically to display the location for creating the new project.

5. You can opt to create the project in a new workspace or choose Add to Current Workspace.

6. Click OK to create the project.

After you click the OK button in the New dialog box, the Project Wizard starts. The following section discusses the various Visual InterDev project wizards in greater detail.

Project Wizards

By using the project wizards, you get a head start on your web-development efforts. The wizards are included primarily to provide a starting point and to automate some of the more mundane tasks involved with developing web applications with Visual InterDev.


TIP: Although it is possible to create a site manually, using one of the wizards as a starting point and then working from the files it creates is a lot faster.

Wizards are available throughout Visual InterDev for expediting routine tasks. The next section discusses the various project wizards.

The Web Project Wizard  You can use the Web Project Wizard to create a simple startup web site. By default, the project created with this wizard will be stored in the publishing root directory of your web server at \inetpub\wwwroot\<project name> directory.

You can start the Web Project Wizard by using the steps outlined in the "Creating Projects" section earlier in this chapter and selecting the Web Project Wizard from the project list in the New dialog box. After the Web Project Wizard starts, follow the steps outlined here:

1. Provide the name of the web server this web project will be connected to. As shown in Figure 14.2, the wizard tries to locate the web server when you click the Next button.

2. The Specify Your Web dialog box appears, as shown in Figure 14.3. Select the appropriate option for creating a new web by providing a name for the web project in the appropriate text box.

3. To provide for search capabilities as part of your web site, select the checkbox next to Enable Full Text Searching for Pages in This Web.

4. Click the Finish button to create the web site.

FIG. 14.2
The Specify the Server for Your Web dialog box is used to specify a web server to host the project being created by the Web Project Wizard.

FIG. 14.3
The Specify Your Web dialog box is used to create a new web or to connect to an existing web site for making modifications and changes.

At this point you are ready to start working with your web site project and add additional files as needed. The search.htm file provides basic functionality for doing full text searches of HTML files within a web site. The first thing you can do is to customize the home page to look like what you need and then add additional HTML pages that can be accessed from the hyperlinks on the home page.


See "The Global.asa File," Chapter 15

The Departmental Site Wizard  The Departmental Site Wizard provides templates for creating an intranet site designed to display departmental information. To create a departmental site, create a new project (as described in the "Creating Projects" section) by selecting the Departmental Site Project. Then follow these steps:

1. Select a web server to host the web site as shown earlier in Figure 14.2. Then click Next to continue.

2. Specify a name for the web site as shown earlier in Figure 14.3. Then click Next to continue.

3. Select the pages that will be a part of your departmental web site. Figure 14.4 shows the choices available to you. Make the appropriate selections and click Next.

FIG. 14.4
The web page choices provide a starting point for various aspects of a typical departmental web site.

4. As shown in Figure 14.5, you provide a name for the department and, optionally, a path to a departmental logo file. Select the other options as appropriate and then click Next.

FIG. 14.5
In Step 4 of the wizard, you can customize the home page to include information such as the last modification date.

5. The Add a Navigation Bar dialog box provides options for Navigation bar placement. The Navigation bar enables users to move between various pages on a web site easily. Select the placement option you want--at the top of each page or at the top and bottom of each page.

6. You can customize a feedback page, as shown in Figure 14.6, for getting feedback from users on various aspects of your web site.

7. To store the feedback obtained from users, the wizard creates a feedback table in a database, as shown in Figure 14.7. Specify a table name and then select a Data Source Name (DSN) by clicking the Select DSN button.

FIG. 14.6
The feedback page can be used to collect useful information from users about how they perceive the web site.

FIG. 14.7
The feedback table must reside in an ODBC-compliant database such as Microsoft Access or SQL Server.

8. The Select DSN button starts the ODBC administrator so that you can define a DSN for connecting to the database where the feedback table will reside. Figure 14.8 shows the main ODBC setup screen.

FIG. 14.8
In the ODBC Select Data Source dialog box, you can select a predefined data source or create a new one.

9. Click Next to display the theme selection page, as shown in Figure 14.9. Select an appropriate theme and click Next to continue.

FIG. 14.9
The wizard provides predefined themes for configuring the look and feel of your web site pages.

10. At this point, the wizard is complete, and you can click Finish to close the wizard and allow it to create the files needed to create the web site.

After the web site is created, you can run and view the site by opening the startup page, or any other page, in a web browser. You can do so from the Visual InterDev IDE by right-clicking the filename in Explorer and selecting Preview in Browser from the pop-up menu.

Sample Application Wizard  The Sample Application Wizard provides a convenient mechanism for installing Visual InterDev sample applications provided by Microsoft on the Visual InterDev CD-ROM or on the Microsoft web site.

To install applications by using the Sample Application Wizard, follow these steps:

1. Select New from the Visual InterDev File menu. The New dialog box appears.

2. Select the Projects tab and then the Sample Application Wizard. Provide a name for the sample application and click OK to continue.

3. The Sample Application Wizard starts and displays the dialog box shown in Figure 14.10.

FIG. 14.10
The Sample Application Wizard can also be used to install third-party web applications.


4. Select a Visual InterDev sample application to install from the list and click Next to continue.


NOTE: Visual InterDev includes two sample applications. These include the Dos Perros Chile Company sample application that demonstrates an Internet web site for doing order entry and catalog browsing. The 401(k) sample application demonstrates a sample intranet application used to track employee benefits information. Other sample applications can be downloaded from the Microsoft web site.


NOTE: The Sample Application Wizard installs all components, such as database tables, needed for installing and running the provided sample web sites.
5. In the Specify a Web Server dialog box, shown in Figure 14.11, supply a name for the web server where the application will be hosted and a name for the application itself. The default choices are usually appropriate. Click Next to continue.

FIG. 14.11
The wizard installs the sample application on the selected web server, where it becomes part of the specified project workspace.

6. If the sample application requires a database, the wizard displays a dialog box for selecting the database, as shown in Figure 14.12.

FIG. 14.12
The database listbox lists the types of databases that can be used to install the sample application tables.

7. Select a shared location where both the web server and the development clients can access the database, as shown in Figure 14.13. Click Next to continue.

FIG. 14.13
The shared database directory must reside on a network drive where both the web server and the development client have access permissions.

8. Click the Finish button to install the sample application.

To run the sample applications, load the start page in Microsoft Internet Explorer and navigate the application pages. Both applications are fairly straightforward and easy to navigate.

Adding Content to a Project

After you have created a Visual InterDev project, either manually or by using a wizard, you are ready to add site-specific content to your web site. The Visual InterDev IDE provides a Windows Explorer-style File View for navigating through your newly created web site project. Figure 14.14 shows the Visual InterDev file viewer.

Several methods are available for adding content to a project. The following sections describe each of these methods in detail.

Creating New Files or Folders

Adding new files or folders in Visual InterDev is quite simple. You can create files of various types, including

FIG. 14.14
The File View shows your web site files and folders in a tree-like structure.

To create a new file or folder for a project, follow these steps:

1. Select New from the File menu or right-click the project or folder name and choose New Folder.


NOTE: The New Folder menu option displays a dialog box where you enter the name of the new folder.


TIP: You can create a new folder as a subfolder of an existing folder by right-clicking that existing folder and selecting New Folder.
2. If you are creating a new file, the New dialog box will be displayed. Select a file type from the Files tab, the File Wizards tab, or the Other Documents tab and provide a name for the file in the text box.

3. Click the Add to Project checkbox to add the file to the current project or a different project.

4. Specify a path to the file location if it is different from the default path displayed.

5. Click OK to create a new file and add it to the root level of the project.


TIP: After a file is created, you can move it to a subfolder within the project by dragging and dropping it on the intended destination folder.

Adding Existing Files or Folders to a Project

To add an existing file to a Visual InterDev project, follow these steps:

1. From the File View, right-click the project name or folder to which you want to add the file or folder. Figure 14.15 shows the shortcut menu that pops up.

FIG. 14.15
The right-click shortcut menu provides access to the most commonly used Visual InterDev commands.

2. Select Add Files from the menu.

3. Select the files to add to the project and click OK to continue.

To add an existing folder to a project, follow these steps:

1. From the File View tab, right-click the project name or folder to which you want to add the folder.

2. From the shortcut menu, select Add Folder Contents.

3. From the ensuing dialog box, select the folder to add. The contents of the folder are added to the project or folder you selected in step 1.

Using Drag and Drop

The File View Explorer supports full drag-and-drop capabilities. To add files or folders through drag and drop, follow these steps:

1. Click a folder or file in the Windows Explorer and drag it to the File View Explorer in Visual InterDev.

2. Drop the file or folder at the location where you want to add it, and the file or folder is added to the project.


NOTE: The drag-and-drop process copies the files to the web server and creates a working copy on the local workstation.

Using File Wizards

Visual InterDev provides a couple of file wizards for adding special files to a project. The following file wizards are provided with Visual InterDev:

The following sections discuss these wizards in further detail.

The Data Form Wizard  The Data Form Wizard is used to create an .ASP file that connects to a database on the back end for displaying dynamic web content on a web page with full search, list, update, delete, and input capabilities. To create a database-enabled file by using the wizard, follow these steps:

1. Select New from the File menu and select the File Wizards tab from the new dialog box.

2. Select the Data Form Wizard and provide a name for your file. Then click Next to start the Data Form Wizard, as shown in Figure 14.16.

FIG. 14.16
The Data Form Wizard creates a form connected to a database table on the back end.

3. In the Data Form Wizard dialog box, select the name of an existing DSN, or create a new one by selecting the New button.

4. Provide a title for the web page and click Next.

5. On the record source page, select the source for your data from the choices provided, as shown in Figure 14.17.

FIG. 14.17
With the Data Form Wizard, you can create a web page based on a table, a stored procedure, a table view, or a SQL statement.

6. In the next step, you choose the source for your data and the fields to be displayed on the page, as shown in Figure 14.18.

FIG. 14.18
From the Table/View drop-down list, you can select the source for your data and the order of the fields.

7. Click the Advanced button to display the dialog box shown in Figure 14.19. In the Advanced Options dialog box, you can provide custom labels for your fields and specify lookup tables for certain fields that derive their display content from other tables in the database. When you have finished with the Advanced Options dialog box, click OK to continue.

FIG. 14.19
The Advanced Options dialog box allows you to further customize the data presentation of your web page.


NOTE: A lookup table is used to derive the display values for a particular field in a table. For example, you might have a lookup table with a customer name and customer ID. Another table might just store the customer ID and use the first table to look up the corresponding customer name.
8. Use the Field Order arrows to rearrange the field display order on the page. Then click Next to continue.

9. Specify the options for editing and displaying your web page, as shown in Figure 14.20. The page can be a display-only page, or it can support add (insert), update (modify), and delete capabilities. Select the appropriate options and click Next to continue.

FIG. 14.20
The Edit Options box enables you to set up whether users can modify information in your form.

10. Select the data display options for your web page, as shown in Figure 14.21. The List View allows you to display a predetermined number of records per page. Select the appropriate options and click Next.

FIG. 14.21
The data can be displayed in Form View or List View.

11. Select the display theme for your page from the options provided and click Next to continue.

12. Click the Finish button to end the wizard and create your web pages. If you select both List and Form View, three different files will be created by the wizard--one for the List View, one for the Form View, and one to include functions for handling data display and other tasks.


See "Exploring the Data Form Wizard," Chapter 15

The Template Page Wizard  The Template Page Wizard is used to create web pages based on a predesigned template, a starting point from which you can customize the web pages. To use the Template Page Wizard, follow these steps:

1. Select New from the File menu and select the Template Page Wizard from the File Wizards page. Provide a name for the page and click OK to start the Template Page Wizard, as shown in Figure 14.22.

FIG. 14.22
The Template Page Wizard can create web pages based on predefined templates.

2. Select the template you want to use and click the Finish button. The wizard creates the appropriate page and adds it to the project.

Visual InterDev Content Development Tools

Visual InterDev provides several content development tools designed to simplify the task of building dynamic web sites. The tools are designed to transfer the focus from the development environment to the development process and include these tools, discussed in detail in the following sections:

Visual InterDev Source Editor

The Visual InterDev Source Editor is in actuality the integrated IDE editor used by all other Visual Studio 97 tools. The Source Editor is similar to other Windows text editors in usability features. Figure 14.23 displays the main Visual InterDev Source Editor.

FIG. 14.23
The Visual InterDev Source Editor is a powerful editor for building applications.

The Source Editor includes functionality designed specifically to make the development process as smooth as possible. Some of these features are

In addition, the source editor provides a right-click shortcut menu for access to the most commonly used commands.


TIP: The source editor enables you to open an Internet address from within the editor by using the Open command on the right-click menu while holding the cursor over an Internet address.

In the Visual InterDev environment, the most common use for the source editor is to edit Active Server Pages files.

The FrontPage 97 HTML Editor

Visual InterDev includes a special edition of the Microsoft FrontPage 97 HTML editor. The FrontPage 97 editor is a WYSIWYG (What You See Is What You Get) HTML editor that makes it easy to build sophisticated layouts and web pages. Figure 14.24 shows the main screen of the FrontPage 97 HTML editor.

FIG. 14.24
The FrontPage 97 HTML editor provides support for ActiveX objects, Java applets, and HTML.

The FrontPage 97 HTML editor is best suited for editing pure HTML files. Do not use it to edit template files or .ASP files. The design-time versions of these files include many scripts that cannot be interpreted by the FrontPage 97 editor.


CAUTION: If you do edit an .ASP file with FrontPage 97, make sure that you do not make changes to the exclamation point areas used to designate scripts, unsupported controls, and such objects. If you double-click the exclamation point, FrontPage 97 attempts to display the code or control designated by that exclamation point.

You can set the FrontPage 97 editor as the default editor for all HTML files. To do this, follow these steps:

1. Create a project that includes an HTML file.

2. Right-click the HTML file to display the shortcut menu and select Open With.

3. In the Open With dialog box, select FrontPage 97 Editor from the list.

4. Click the Set as Default button to set FrontPage 97 as the default editor for all HTML files.


TIP: You can set any third-party editor as the default editor for HTML files by using the Add button in the Open With dialog box.

Other Tools

In addition to the two content-development tools described in the previous sections, the Visual Studio environment includes other tools that play a pivotal role in developing useful web sites. These include

Server-Side ActiveX Components

Visual InterDev includes a facility for utilizing ActiveX components in the server environment. These are ActiveX components that execute on the server and provide a means to integrate web applications with traditional client/server applications. Server-side ActiveX components are utilized by the Active Server scripting mechanism to provide productivity gains by encapsulating business rules into components.


See "Using Server-Side Scripting with Visual InterDev," Chapter 17


NOTE: An ActiveX Server component is nothing more than an OLE Automation Server that can be created by using any tool that supports OLE Automation Server creation. Such tools include Visual C++, Visual Basic, Delphi, and PowerBuilder.

One of the most important benefits of server-side ActiveX components is their capability to provide a wrapper mechanism around existing legacy and client/server applications. ActiveX server components are most easily created by using tools such as Visual Basic. After being created, the components can be used in Visual InterDev to integrate into a web application.


NOTE: An ActiveX server component is distinct from an ActiveX client component in that it does not include any graphical user-interface elements.

ActiveX servers provide a reuse mechanism for commonly used code. A variety of applications and tools are coming out that provide support for ActiveX server components by exposing their properties and methods as packaged components.

Using ActiveX Server Components in Visual InterDev

Visual InterDev provides scripting support for creating and instantiating ActiveX server components as part of Active Server Page scripts. The following sample code uses a server-side component called UserInfo to display information from a database about the user connected to the web server.


For more information about creating ActiveX server components, see Chapter 5, "Creating ActiveX Components with Visual Basic."
Set UserInf = Server.CreateObject("UserInfo.UserInfo")
If Not UserInf.Status Then
      display error code and exit
Else
UserInf.GetUserInformation
End If

The preceding sample code performs a variety of tasks through the use of the UserInfo ActiveX server component. The CreateObject method instantiates the UserInfo object and establishes a connection to the database that is verified by the Status property being set to True. After a user connects to the web server, the GetUserInformation method obtains the user info from the database and displays it by using the Response object to write the results to the client.

Distributing Components by Using DCOM

The DCOM specification provides mechanisms for distributing objects across the network on different machines. This is a powerful concept that enables you to run your ActiveX components on machines other than the web server, possibly because the ActiveX server component is nothing more than an OLE Automation Server.

DCOM provides a powerful means of distributing load and processing power across multiple machines within an enterprise; however, the utility (dcomcfg.exe) used to distribute ActiveX server components over different machines can do this only for out-of-process servers.


NOTE: The Active Server Pages (ASP) must be enabled to use out-of-process components by setting the following Registry key to 1:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\ASP\Parameters\AllowOutOfProcCmpnts

You can use regedt32.exe to change the Registry setting manually.


A more powerful method of distributing server components is to leverage the power of the Microsoft Transaction Server for distributing in-process and out-of-process server components.


For more information about distributing and managing server components through Microsoft Transaction Server, see Chapter 25, "Using Microsoft Transaction Server to Enable Distributed Applications."

ActiveX Server Components Included with Visual InterDev

Microsoft supplies prebuilt ActiveX server components with Visual InterDev to accomplish some common and frequently used tasks. These include

The following sections describe these components in further detail.

Advertisement Rotator  The Advertisement Rotator component automatically cycles through advertisements displayed on a page, based on a predetermined sequence. The main purpose of the Advertisement Rotator component is to provide a mechanism for web sites to display advertisements for revenue generation.

The Advertisement Rotator component uses the Rotator Schedule File to determine the sequence and schedule for displaying various advertisements. The component uses the following files for implementing its functionality:

The Advertisement Rotator component supports the following properties and methods:

The following code sample shows how the preceding methods can be used to display an advertisement on a web page:

<% Set ad = Server.CreateObject("MSWC.AdRotator")
ad.Border(0)
ad.Clickable(FALSE)
ad.TargetFrame(Frame1)
%>
<%
ad.GetAdvertisement("/scripts/adrot.txt")
%>

The preceding code sample sets the advertisement properties and then displays the advertisement, using the GetAdvertisement method.

Browser Capabilities  The Browser Capabilities component provides information on the features supported by a client browser. By knowing the capabilities of a user's browser, developers can tailor their HTML content to more closely match the browser's feature set.

The Active Server Pages provide a file called browscap.ini, which includes information about the capabilities of various browsers. When a browser requests a page from a web server, the HTTP header sent by the browser also includes information about itself. The Browser Capabilities component then compares the information in the HTTP header against the browscap.ini file and sends the information to the server.


NOTE: The browscap.ini file is located in the c:\winnt\system32\intesrv\ASP\cmpnts directory. The browscap.dll component file also resides in the same directory.

The format of the browscap.ini file is similar to any other .INI files included with Windows. The file includes separate sections for various browsers, which define the properties of the respective browsers. The following listing shows a few sections of the browscap.ini file:

;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Microsoft Browsers ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
[Microsoft Internet Explorer/4.40.308 (Windows 95) ]
browser=IE
version=1.0
majorver=#1
minorver=#0
frames=FALSE
tables=FALSE
cookies=FALSE
backgroundsounds=FALSE
vbscript=FALSE
javascript=FALSE
javaapplets=FALSE
platform=Windows95
[IE 1.5]
browser=IE
version=1.5
majorver=#1
minorver=#5
frames=FALSE
tables=TRUE
cookies=TRUE
backgroundsounds=FALSE
vbscript=FALSE
javascript=FALSE
javaapplets=FALSE
beta=False
Win16=False
[Mozilla/1.22 (compatible; MSIE 1.5; Windows NT)]
parent=IE 1.5
platform=WinNT
[Mozilla/1.22 (compatible; MSIE 1.5; Windows 95)]
parent=IE 1.5
platform=Win95
;;ie 2.0
[IE 2.0]
browser=IE
version=2.0
majorver=#2
minorver=#0
frames=FALSE
tables=TRUE
cookies=TRUE
backgroundsounds=TRUE
vbscript=FALSE
javascript=FALSE
javaapplets=FALSE
beta=False
Win16=False

The Browser Capabilities component can be used in an .ASP file to determine the capabilities of a browser, as shown in the code listing that follows:

<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<%Set brows = Server.CreateObject("MSWC.BrowserType")%>
Browser <%= brows.browser%>
Version <%=brows.version%>
</BODY>
</HTML>

The preceding code sample instantiates a Browser Capabilities object and uses some of its properties to determine the browser name and version information.


NOTE: The Browser Capabilities component does not have any methods associated with it.

TextStream  The TextStream component, together with the FileSystem object, is used to create, open, read, and write to text files. The FileSystem object is used for the simple purpose of creating and opening text files. It has no properties and includes two methods:

The following code illustrates the use of a FileSystem object:

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set txtfile = FSO.CreateTextFile("c:\test.txt", True)
txtfile.WriteLine("This is a test.")
txtfile.Close

In the preceding sample, the CreateObject method creates a FileSystem object. The FileSystem object's CreateTextFile method is then used to instantiate a TextStream object. The TextStream object uses the WriteLine and Close methods to write to the text file.

The TextStream object has the following properties and methods:

Content Linking  The Content Linking component provides a mechanism for creating a table of contents for your web site. It accomplishes this task by using a Content Linking list file. The Content Linking list file is a simple ASCII text file that includes entries for page URLs and their descriptions.

A sample Content Linking list file is presented following:

---LINKLIST.TXT---
default.htm   Home Page
about.htm   About the Company
Marketing.htm   Marketing Department Web Page
Acct.htm   Accounting Department Web Page

The Content Linking component supports the following methods:

The following example demonstrates the building of a table of contents based on a Content Linking list file named linklist.txt in the /scripts virtual directory:

<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<% Set CL = Server.CreateObject ("MSWC.NextLink") %> 
<% count = CL.GetListCount ("/scripts/linklist.txt") %> 
<% I = 1 %> 
<ul>
<% Do While (I <= count) %> 
<li><a href=" <%= CL.GetNthURL ("/scripts/linklist.txt", I) %> "> 
<%= CL.GetNthDescription ("/scripts/linklist.txt", I) %> </a> 
<% I = (I + 1) %> 
<% Loop %> 
</ul>
</BODY>
</HTML>

Client-Side Components

Client-side components are ActiveX controls or Java applets that are integrated into an HTML page and downloaded to a client computer before they can be used by the browser. For the client-side component to run in the browser, both the browser and the operating system must support it.

Visual InterDev provides support for using and incorporating client-side components into the web page through the source editor and the FrontPage 97 editor. The following sections describe how the Visual InterDev environment can be used to leverage the power of client-side components for building exciting web sites.

ActiveX Controls

ActiveX controls are compiled components that provide specific functionality. Thousands of ActiveX controls for performing a variety of tasks are available for use in application-building tools such as Visual InterDev, Visual Basic, Visual C++, Delphi, PowerBuilder, and many others.


NOTE: Currently, ActiveX controls are supported on the Windows and Macintosh platforms, with support for UNIX slated in the near future.

Because ActiveX controls are platform-specific, they are not portable from environment to environment, and a different compiled version must be supplied for each supported platform. However, the platform dependence allows ActiveX controls to take advantage of platform-specific features and functionality.

Using ActiveX controls in Visual InterDev is very simple and straightforward. You can use either the Visual InterDev Source Editor or FrontPage 97 to automate the insertion of ActiveX controls in web pages.

To use ActiveX controls on an HTML or ASP page, follow these steps:

1. Open the HTML or ASP page on which the control will be placed.

2. Place the cursor where you want to insert the control and right-click to get to the shortcut menu, as shown in Figure 14.25.

FIG. 14.25
The Insert options can be used to place various controls into the current page.

3. Select the Insert ActiveX Control from the menu to display the Insert ActiveX Control dialog box, shown in Figure 14.26.

FIG. 14.26
The Insert ActiveX Control dialog box lists all the registered controls on your machine.

4. Select the control to insert, and click OK to display the control's image and Properties dialog box, as shown in Figure 14.27.

FIG. 14.27
Set the initial values for the various control properties by using the Properties dialog box.

5. Close the control page. The HTML for the control is displayed in the Visual InterDev Source Editor.

In addition, you can use FrontPage 97 to insert controls into HTML pages in WYSIWYG mode. The controls can even be inserted by using drag and drop. The object editor used in FrontPage 97 is the same as the one used in Visual InterDev Source Editor.

Java Applets

Java applets, like ActiveX controls, are software programs that can be inserted into HTML pages. Java applets are available for creating anything from user interface elements to games and full-blown applications.

Java applets are unique in that they are platform-independent. Any platform that has a Java virtual machine can run Java applet code with no need to recompile for different platforms.


CAUTION: The platform-independent nature of Java applets makes them unsuitable for utilizing platform-specific functionality. Java applets adhere to the "least-common-denominator" philosophy of cross-platform support.

The easiest way to insert a Java applet into an HTML page is to use the FrontPage 97 editor. Follow these steps:

1. Open the HTML page in FrontPage 97.

2. From the Editor menu, choose Insert, Other Component, Java Applet.

3. The Java Applet Properties dialog box appears, as shown in Figure 14.28.

FIG. 14.28
The Java Applet Properties dialog box can be used to set runtime properties for your applet.

4. Provide the .Class filename with the full path to the object in the Applet Source text box. The .Class file is the object file that contains the compiled Java applet runtime.

5. In the Applet Base URL text box, supply the URL to the Java .Class file. This defines where the Java applet file is stored on the web server.

6. In the Message for Browsers Without Java Support text box, provide an HTML message for browsers that do not support Java applets.

7. Add the values for each parameter you want to pass to the Java applet.


NOTE: Because Java provides no means for displaying properties and their associated values for applets, you will have to consult the applet documentation for the correct parameters and values.
8. In the Layout property area, specify the display properties for the Java applet.

9. Click OK to close the Properties dialog box and insert the Java applet into your HTML source.

Besides using FrontPage 97 to insert Java applets into web pages, Java applets can also be hosted by Visual J++ within the same workspace as Visual InterDev in the Visual Studio 97 IDE.

From Here...

In this chapter, you learned about some of the basic features and functionality of Visual InterDev. You learned how to use the Visual Studio IDE to create Visual InterDev projects, how to add content to those projects, and how to use wizards to maximize your efforts. You also learned about using and incorporating server-side and client-side components into your projects.

Refer to the following chapters for information related to building web sites and web-based applications using Visual InterDev:


Previous chapterNext chapterContents


© Copyright, Macmillan Computer Publishing. All rights reserved.