
by Azam A. Mirza
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.
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.
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:
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.
The next section outlines the procedures for creating web projects within Visual InterDev.
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:
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.
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.
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.
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:
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:
FIG. 14.4
The web page choices provide a starting point for various aspects of a typical departmental
web site.
FIG. 14.5
In Step 4 of the wizard, you can customize the home page to include information such
as the last modification date.
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.
FIG. 14.8
In the ODBC Select Data Source dialog box, you can select a predefined data source
or create a new one.
FIG. 14.9
The wizard provides predefined themes for configuring the look and feel of your web
site pages.
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:
FIG. 14.10
The Sample Application Wizard can also be used to install third-party web applications.
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.
FIG. 14.11
The wizard installs the sample application on the selected web server, where it
becomes part of the specified project workspace.
FIG. 14.12
The database listbox lists the types of databases that can be used to install the
sample application tables.
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.
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.
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.
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:
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.
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.
To add an existing file to a Visual InterDev project, follow these steps:
FIG. 14.15
The right-click shortcut menu provides access to the most commonly used Visual
InterDev commands.
To add an existing folder to a project, follow these steps:
The File View Explorer supports full drag-and-drop capabilities. To add files or folders through drag and drop, follow these steps:
NOTE: The drag-and-drop process copies the files to the web server and creates a working copy on the local workstation.
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:
FIG. 14.16
The Data Form Wizard creates a form connected to a database table on the back end.
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.
FIG. 14.18
From the Table/View drop-down list, you can select the source for your data and the
order of the fields.
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.
FIG. 14.20
The Edit Options box enables you to set up whether users can modify information in
your form.
FIG. 14.21
The data can be displayed in Form View or List View.
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:
FIG. 14.22
The Template Page Wizard can create web pages based on predefined templates.
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:
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.
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:
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.
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
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.
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.
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\AllowOutOfProcCmpntsYou 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."
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 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 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:
FIG. 14.25
The Insert options can be used to place various controls into the current page.
FIG. 14.26
The Insert ActiveX Control dialog box lists all the registered controls on your
machine.
FIG. 14.27
Set the initial values for the various control properties by using the Properties
dialog box.
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, 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:
FIG. 14.28
The Java Applet Properties dialog box can be used to set runtime properties for
your 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.
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.
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:
© Copyright, Macmillan Computer Publishing. All rights reserved.