HOME
BACK
FORWARD
TOC

Day 21

Putting It All Together: The Publishers Paradise Case Study

The final day of your intense Visual InterDev training has arrived. It seems like only yesterday that you began this journey. You have learned a lot of material in a relatively short time. The best way to reinforce your learning is to apply it, which this lesson gives you a chance to do. Your three weeks of training ends with a case study of an application you help finish. You will be completing an intranet application for Publishers' Paradise, a large, hypothetical conglomerate that owns several publishing companies. This application gives you a chance to apply all the knowledge you've gained in the past three weeks to build a Web-based application. You should also get a feel for how the components fit together to meet users' needs. The lesson gives you a lot of the code so you can concentrate on learning how the pieces fit together, instead of worrying about strict programming.

The first part of the lesson describes the application and its purpose and explains the different components you will be working with to build the application. Next, you jump right into development by creating the client components, including HTML, ActiveX, VBScript, images, and music. You then integrate the server components into the application equation. These components include Active Server Pages and database connectivity. Next, you combine the client and the server to examine and test the results. At the end of the day, the lesson debriefs the case study. I bet you can't wait to start!

The Art of Application

Trainers agree that you must use the information and knowledge you gain during a course to truly lock it into long-term memory. You must apply the knowledge you learn to become proficient; in other words, true mastery comes only with practice. You have chosen to learn Visual InterDev by working through this book, so I would be remiss if I didn't give you a way to apply the knowledge before you tackle your real-world applications. During this lesson, you get to apply your knowledge and determine how much you have learned. If you discover that you need to brush up on some concept, feel free to refer to the lesson on that topic. This final examination is an open book test.

The Publishers Paradise Case Study at a Glance

This case study involves developing an intranet application for Publishers' Paradise. As mentioned, Publishers' Paradise is one of the largest publishing conglomerates in the country. It owns several companies that publish many different types of books. This case study is a hypothetical situation, but it's meant to demonstrate the possibilities for Web-based applications.

This section reviews the application so you will understand the final product. This application is targeted at managers who are responsible for monitoring the progress and sales of books. At its core, the application enables a manager to track the sales of a company's books. The manager can also view a list of current titles and their prices. Publishers' Paradise is known for its reliability and impeccable service, which is made possible, in part, by this application.

Creating the Client Components

The Publishers' Paradise intranet application uses several different client components, including HTML web pages, scripting code, images, ActiveX controls, and music. You will be using all these components to construct the client portion of the application. Some of these pieces are given to you as part of the lesson, and others you create from scratch. Again, the goal is to reinforce your learning over the past three weeks.


NOTE: For this lesson, you need to open the project workspace in the Publishers' Paradise directory on this book's CD-ROM. This project has everything you need to complete the application. Also, this application uses a connection to the SQL Server Pubs sample database, which is also supplied on the CD-ROM.

Creating the HTML Web Pages

The first step of this case study is to create the HTML web pages that house the application's other client components. Table 21.1 lists and describes the three HTML web pages in the application.

Table 21.1. The HTML web pages.

Web Page Description
Default.htm Main introduction page for the application
News.htm Contains news flashes about the company
Reports.htm Displays a list of available reports that can be viewed

The following sections evaluate each of these web pages.

The Default Page

This page is the first, or default, page of the application. Figure 21.1 displays this page's layout.

From this page, a manager can navigate to any of the other web pages in the application. To construct this page, you need to open the web page called Default.htm that's in the PubParadise project with the FrontPage Editor for Visual InterDev. This file provides a shell you can use to further develop the web page. Once you open the file, your screen should look like the one shown in Figure 21.2.

Next, you need to create the hyperlinks for the other pages that can be accessed from this page. The names of these files were given in Table 21.1, and the files are included as part of the PubParadise project. You can easily incorporate hyperlinks to these files by using the FrontPage Editor.

Figure 21.1.

The default page.

Figure 21.2.

Opening the page with the FrontPage Editor.



TIP: I will periodically give you tips during this lesson as a refresher to get you going in the right direction. You might want to ignore the tips and see whether you can complete the task without any help. You can then check the tip to see whether you performed the task in the same way.
The first tip is about creating hyperlinks with the FrontPage Editor. You should open the linked pages with the FrontPage Editor to make the process simpler. Next, place your cursor at the desired location in the main web page and type the text that represents and describes the link. This is the text displayed on the web page to the user. Then highlight the text and choose Hyperlink from the Insert menu. You should be able to pick the open page from a list and click OK. Figure 21.3 shows an example of this window.

Figure 21.3.

Choosing a hyperlink.

When you have finished inserting the hyperlinks, your default web page should resemble the page shown in Figure 21.4.

Figure 21.4.

The links revealed.

The next task is to spice up the look and behavior of this page so it seems more hospitable to the user. The PubParadise project has a GIF image and a MIDI sound file you can use to jazz up the page. You need to use the FrontPage Editor to insert the image in the top-right corner of the default page. You should insert the MIDI file as a background sound.


TIP: Use the Insert menu to help you perform this task.

The default page still has something missing. You need to insert the page's title and purpose, as well as a horizontal line between the header and the body of the web page. After you finish this final task, your web page should look like the one in Figure 21.5.

In a few steps, you have constructed the application's default page. The FrontPage Editor helped you construct the web page without worrying about the underlying HTML. Listing 21.1 shows you the HTML created so far, based on your design.

Listing 21.1. The default web page code.


<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR"
content="Microsoft FrontPage (Visual InterDev Edition) 2.0">
<title>Document Title</title>
<bgsound
src="file:///C:/Program%20Files/DevStudio/MyProjects/PubParadise/opening.mid"
loop="1">
</head>
<body>
<p><img
src="file:///C:/Program%20Files/DevStudio/MyProjects/PubParadise/images/books.gif"
align="left" hspace="0" width="121" height="149"></p>
<p align="center"><font size="5"><strong>Welcome to the
Publishers' Paradise!</strong></font></p>
<p align="center"><font size="4">Click on a hyperlink to begin
the journey.</font></p>
<p>&nbsp;</p>
<hr>
<p><a href="news.htm">News</a></p>
<p><a href="reports.htm">Reports</a></p>
</body>
</html>

Figure 21.5.

The completed default page.

This code uses hyperlinks to serve as the main link to the other areas of the application. This page also has background music that plays when the user first gets to this page. The music is a MIDI file created with the Music Producer, and the image is a GIF file designed with the Image Composer.

The News Page

This web page has news updates for Publishers' Paradise employees; its contents have already been developed, as shown in Figure 21.6.

Figure 21.6.

The News page: Life in Paradise.

As you can see, this page offers several brief company articles; it's updated daily by the marketing department.

The Reports Page

The Reports page displays a hyperlink list of all the available reports for the application. These links are associated with their respective Active Server Pages (ASPs), which retrieve the necessary information from the database and display it in a report format. Some of these reports consist of tables, and other reports display the information in a graph. This page has also been created for you as part of the PubParadise project and is displayed in Figure 21.7.

Figure 21.7.

The Reports page.

Creating the Server Components

Now that you have constructed the client portion of the application, it's time to build the server components, which include ASPs and database integration. Table 21.2 lists the ASPs included with the application.

Table 21.2. The ASP files.

ASP File Description
Titles.asp Report that displays all the published books
Sales.asp Report that displays sales information for the whole company

The following sections present and explain these ASPs.

The Titles ASP

The Titles ASP enables you to view all the available books published by Publishers' Paradise. You construct this page by using the Titles.asp file contained in the project. This file is just a shell into which you insert the design-time controls for building the database query and table. You can then add the logic to display the information in the table.

Inserting the Data Range Controls

The first step to creating the Titles ASP is to insert the Data Range Header and Footer controls. You can choose between two methods to insert these controls. Can you remember what those methods are? Refer back to Day 14, "Extending Web Pages Through Design-Time Controls," for a reminder.

During this process, you must make some choices about the kind of data you want to retrieve and how you want to format it. Table 21.3 lists the values that you should choose for the Data Range Header control.

Table 21.3. Property table for the Data Range Header control.

Property Value
Data Connection Pubs
Command Type SQL
Range Type Table
Record Paging Enabled
Page Size 20
Cursor Type Keyset

After you establish these values for the properties, you need to build an SQL statement that will retrieve the Title, Type, PubDate, Price, and YTD_Sales columns from the Titles table. If you need help constructing the query, refer to the lesson on Day 9, "Using the Visual Data Tools for Maximum Productivity." After you build the query and return to the Properties window for the Data Range Header control, you need to copy all the fields you're selecting from the Titles table. You can do this by clicking the Copy Fields button.

Formatting the Results

Now that you have inserted the proper design-time controls to retrieve the data, you're ready to insert some logic to properly format the results in a table. The following lines of code need to be inserted between the Data Range Header and Footer controls:


<TR>
<TD> <%Response.Write DataRangeHdr1("title")%> </TD>
<TD> <%Response.Write DataRangeHdr1("type")%></TD>
<TD><%Response.Write DataRangeHdr1("pubdate") %></TD>
<TD><%Response.Write FormatCurrency(DataRangeHdr1("price"),2) %></TD>
<TD><%Response.Write DataRangeHdr1("ytd_sales") %></TD>
</TR>

This code example writes the individual data fields into their respective table columns for each row that's returned. The FormatCurrency function is used to format the Price field to display values with a dollar sign and two decimals. You also need to define the table width and border by entering the following lines of code at the beginning of the body section, just before the declaration for the Data Range Header control:


<TABLE WIDTH=100% BORDER=3>
<TR><TH>Title</TH><TH>Type</TH><TH>Published Date</TH>
<TH>Price</TH><TH>YTD Sales</TH></TR>

After you have entered this code, your ASP file's contents should resemble the code in Listing 21.2.

Listing 21.2. The Titles ASP code.

<%@ 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>Book Titles Report</TITLE>
</HEAD>
<BODY>
<TABLE WIDTH=100% BORDER=3>
<TR><TH>Title</TH><TH>Type</TH><TH>Published Date</TH>
<TH>Price</TH><TH>YTD Sales</TH></TR>

<!--METADATA TYPE="DesignerControl" startspan
<OBJECT ID="DataRangeHdr1" WIDTH=151 HEIGHT=24
CLASSID="CLSID:F602E721-A281-11CF-A5B7-0080C73AAC7E">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3986">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
<PARAM NAME="DataConnection" VALUE="pubs">
<PARAM NAME="CommandText" VALUE="SELECT title, type, pubdate, 
price, ytd_sales FROM titles">
<PARAM NAME="CursorType" VALUE="1">
<PARAM NAME="RangeType" VALUE="2">
<PARAM NAME="PageSize" VALUE="20">
</OBJECT>
-->
<%
fHideNavBar = False
fHideNumber = False
fHideRequery = False
fHideRule = False
stQueryString = ""
fEmptyRecordset = False
fFirstPass = True
fNeedRecordset = False
fNoRecordset = False
tBarAlignment = "Left"
tHeaderName = "DataRangeHdr1"
tPageSize = 20
tPagingMove = ""
tRangeType = "Table"
tRecordsProcessed = 0
tPrevAbsolutePage = 0
intCurPos = 0
intNewPos = 0
fSupportsBookmarks = True
fMoveAbsolute = False
If Not IsEmpty(Request("DataRangeHdr1_PagingMove")) Then
tPagingMove = Trim(Request("DataRangeHdr1_PagingMove"))
End If
If IsEmpty(Session("DataRangeHdr1_Recordset")) Then
fNeedRecordset = True
Else
If Session("DataRangeHdr1_Recordset") Is Nothing Then
fNeedRecordset = True
Else
Set DataRangeHdr1 = Session("DataRangeHdr1_Recordset")
End If
End If
If fNeedRecordset Then
Set pubs = Server.CreateObject("ADODB.Connection")
pubs.ConnectionTimeout = Session("pubs_ConnectionTimeout")
pubs.CommandTimeout = Session("pubs_CommandTimeout")
pubs.Open Session("pubs_ConnectionString"), 
Session("pubs_RuntimeUserName"), Session("pubs_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataRangeHdr1 = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT title, type, pubdate, price, ytd_sales FROM  Â titles"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = pubs
DataRangeHdr1.Open cmdTemp, , 1, 1
End If
On Error Resume Next
If DataRangeHdr1.BOF And DataRangeHdr1.EOF Then fEmptyRecordset = True
On Error Goto 0
If Err Then fEmptyRecordset = True
DataRangeHdr1.PageSize = tPageSize
fSupportsBookmarks = DataRangeHdr1.Supports(8192)
If Not IsEmpty(Session("DataRangeHdr1_Filter")) And Not fEmptyRecordset Then
DataRangeHdr1.Filter = Session("DataRangeHdr1_Filter")
If DataRangeHdr1.BOF And DataRangeHdr1.EOF Then fEmptyRecordset = True
End If
If IsEmpty(Session("DataRangeHdr1_PageSize")) Then 
Session("DataRangeHdr1_PageSize") = tPageSize
If IsEmpty(Session("DataRangeHdr1_AbsolutePage")) Then ÂSession("DataRangeHdr1_AbsolutePage") = 1
If Session("DataRangeHdr1_PageSize") <> tPageSize Then ÂtCurRec = 
	((Session("DataRangeHdr1_AbsolutePage") - 1) 
	* ÂSession("DataRangeHdr1_PageSize")) + 1
tNewPage = Int(tCurRec / tPageSize)
If tCurRec Mod tPageSize <> 0 Then
tNewPage = tNewPage + 1
End If
If tNewPage = 0 Then tNewPage = 1
Session("DataRangeHdr1_PageSize") = tPageSize
Session("DataRangeHdr1_AbsolutePage") = tNewPage
End If
If fEmptyRecordset Then
fHideNavBar = True
fHideRule = True
Else
tPrevAbsolutePage = Session("DataRangeHdr1_AbsolutePage")
Select Case tPagingMove
Case ""
fMoveAbsolute = True
Case "Requery"
DataRangeHdr1.Requery
fMoveAbsolute = True
Case "<<"
Session("DataRangeHdr1_AbsolutePage") = 1
Case "<"
If Session("DataRangeHdr1_AbsolutePage") > 1 Then
Session("DataRangeHdr1_AbsolutePage") = Session("DataRangeHdr1_AbsolutePage") - 1
End If
Case ">"
If Not DataRangeHdr1.EOF Then
Session("DataRangeHdr1_AbsolutePage") = Session("DataRangeHdr1_AbsolutePage") + 1
End If
Case ">>"
If fSupportsBookmarks Then
Session("DataRangeHdr1_AbsolutePage") = DataRangeHdr1.PageCount
End If
End Select
Do
If fSupportsBookmarks Then
DataRangeHdr1.AbsolutePage = Session("DataRangeHdr1_AbsolutePage")
Else
If fNeedRecordset Or fMoveAbsolute Or DataRangeHdr1.EOF Then
DataRangeHdr1.MoveFirst
DataRangeHdr1.Move (Session("DataRangeHdr1_AbsolutePage") - 1) * tPageSize
Else
intCurPos = ((tPrevAbsolutePage - 1) * tPageSize) + tPageSize
intNewPos = ((Session("DataRangeHdr1_AbsolutePage") - 1) * tPageSize) + 1
DataRangeHdr1.Move intNewPos - intCurPos
End If
If DataRangeHdr1.BOF Then DataRangeHdr1.MoveNext
End If
If Not DataRangeHdr1.EOF Then Exit Do
Session("DataRangeHdr1_AbsolutePage") = Session("DataRangeHdr1_AbsolutePage") - 1
Loop
End If
Do
If fEmptyRecordset Then Exit Do
If tRecordsProcessed = tPageSize Then Exit Do
If Not fFirstPass Then
DataRangeHdr1.MoveNext
Else
fFirstPass = False
End If
If DataRangeHdr1.EOF Then Exit Do
tRecordsProcessed = tRecordsProcessed + 1
%>
<!--METADATA TYPE="DesignerControl" endspan-->
<TR>
<TD> <%Response.Write DataRangeHdr1("title")%> </TD>
<TD> <%Response.Write DataRangeHdr1("type")%></TD>
<TD><%Response.Write DataRangeHdr1("pubdate") %></TD>
<TD><%Response.Write FormatCurrency(DataRangeHdr1("price"),2) %></TD>
<TD><%Response.Write DataRangeHdr1("ytd_sales") %></TD>
</TR>
<!--METADATA TYPE="DesignerControl" startspan
<OBJECT ID="DataRangeFtr1" WIDTH=151 HEIGHT=24
CLASSID="CLSID:F602E722-A281-11CF-A5B7-0080C73AAC7E">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3969">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
</OBJECT>
-->
<%
Loop
If tRangeType = "Table" Then Response.Write "</TABLE>"
If tPageSize > 0 Then
If Not fHideRule Then Response.Write "<HR>"
If Not fHideNavBar Then
%>
<TABLE WIDTH=100% >
<TR>
<TD WIDTH=100% >
<P ALIGN=<%= tBarAlignment %> >
<FORM <%= "ACTION=""" & Request.ServerVariables("PATH_INFO") & 
stQueryString & """" %> METHOD="POST">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &lt;&lt;   ">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &lt;    ">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="    &gt;   ">
<% If fSupportsBookmarks Then %>
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &gt;&gt;   ">
<% End If %>
<% If Not fHideRequery Then %>
<INPUT TYPE="Submit" NAME="<% =tHeaderName & "_PagingMove" %>" 
VALUE=" Requery ">
<% End If %>
</FORM>
</P>
</TD>
<TD VALIGN=MIDDLE ALIGN=RIGHT>
<FONT SIZE=2>
<%
If Not fHideNumber Then
If tPageSize > 1 Then
Response.Write "<NOBR>Page: " & Session(tHeaderName & "_AbsolutePage") & 
"</NOBR>"
Else
Response.Write "<NOBR>Record: " & Session(tHeaderName & "_AbsolutePage") & 
"</NOBR>"
End If
End If
%>
</FONT>
</TD>
</TR>
</TABLE>
<%
End If
End If
%>
<!--METADATA TYPE="DesignerControl" endspan-->

</BODY>
</HTML>

You can preview the results by browsing the ASP web page, as illustrated in Figure 21.8.

Figure 21.8.

Viewing the titles.

The Sales Report

You also need to create the ASP to process the Sales report for the application. This report displays the year-to-date sales for the different types of books published by Publishers' Paradise. The ASP for this report is named Sales.asp and is located in the PubParadise project.

First, you need to open the ASP and insert the Data Range Header and Footer controls into the ASP. Next, create a query that retrieves the Type column and totals the Ytd_Sales column. The following code shows what your SQL statement should look like:


Select type, SUM(ytd_sales)
FROM titles
GROUP BY type

You should practice using the Query Designer to construct this query instead of typing the SQL statement directly. After you insert the Data Range Header and Footer controls, insert the following lines of code between the Data Range Header and Footer controls:


<TR>
<TD> <%Response.Write DataRangeHdr1("type")%> </TD>
<TD><%Response.Write FormatCurrency(DataRangeHdr1(1),0,,,-2) %></TD>
</TR>

In this code example, the FormatCurrency function is used to format the Total Sales column with a dollar sign and a comma separator. Notice the other method to refer to the second column that's returned from the database. You can access a column by referring to it either by name or by its index number.

You also need to insert the following lines of code at the top of the body section:

<TABLE WIDTH=100% BORDER=3>
<TR><TH>Book Type</TH><TH>Total Sales</TH></TR>

After you finish these tasks, your final ASP should contain the code in Listing 21.3.

Listing 21.3. The Sales ASP code.

<%@ 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>Sales Report</TITLE>
</HEAD>
<BODY>
<TABLE WIDTH=100% BORDER=3>
<TR><TH>Book Type</TH><TH>Total Sales</TH></TR>

<!--METADATA TYPE="DesignerControl" startspan
<OBJECT ID="DataRangeHdr1" WIDTH=151 HEIGHT=24
CLASSID="CLSID:F602E721-A281-11CF-A5B7-0080C73AAC7E">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3986">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
<PARAM NAME="DataConnection" VALUE="pubs">
<PARAM NAME="CommandText" VALUE="SELECT type, SUM(ytd_sales) 
FROM titles GROUP BY type">
<PARAM NAME="RangeType" VALUE="2">
</OBJECT>
-->
<%
fHideNavBar = False
fHideNumber = False
fHideRequery = False
fHideRule = False
stQueryString = ""
fEmptyRecordset = False
fFirstPass = True
fNeedRecordset = False
fNoRecordset = False
tBarAlignment = "Left"
tHeaderName = "DataRangeHdr1"
tPageSize = 0
tPagingMove = ""
tRangeType = "Table"
tRecordsProcessed = 0
tPrevAbsolutePage = 0
intCurPos = 0
intNewPos = 0
fSupportsBookmarks = True
fMoveAbsolute = False
If IsEmpty(Session("DataRangeHdr1_Recordset")) Then
fNeedRecordset = True
Else
If Session("DataRangeHdr1_Recordset") Is Nothing Then
fNeedRecordset = True
Else
Set DataRangeHdr1 = Session("DataRangeHdr1_Recordset")
End If
End If
If fNeedRecordset Then
Set pubs = Server.CreateObject("ADODB.Connection")
pubs.ConnectionTimeout = Session("pubs_ConnectionTimeout")
pubs.CommandTimeout = Session("pubs_CommandTimeout")
pubs.Open Session("pubs_ConnectionString"), 
Session("pubs_RuntimeUserName"), Session("pubs_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataRangeHdr1 = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT type, SUM(ytd_sales) FROM titles GROUP BY type"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = pubs
DataRangeHdr1.Open cmdTemp, , 0, 1
End If
On Error Resume Next
If DataRangeHdr1.BOF And DataRangeHdr1.EOF Then fEmptyRecordset = True
On Error Goto 0
If Err Then fEmptyRecordset = True
If Not IsEmpty(Session("DataRangeHdr1_Filter")) And Not fEmptyRecordset Then
DataRangeHdr1.Filter = Session("DataRangeHdr1_Filter")
If DataRangeHdr1.BOF And DataRangeHdr1.EOF Then fEmptyRecordset = True
End If
If fEmptyRecordset Then
fHideNavBar = True
fHideRule = True
End If
Do
If fEmptyRecordset Then Exit Do
If Not fFirstPass Then
DataRangeHdr1.MoveNext
Else
fFirstPass = False
End If
If DataRangeHdr1.EOF Then Exit Do
%>
<!--METADATA TYPE="DesignerControl" endspan-->
<TR>
<TD> <%Response.Write DataRangeHdr1("type")%> </TD>
<TD><%Response.Write FormatCurrency(DataRangeHdr1(1),0,,,-2) %></TD>
</TR>

<!--METADATA TYPE="DesignerControl" startspan
<OBJECT ID="DataRangeFtr1" WIDTH=151 HEIGHT=24
CLASSID="CLSID:F602E722-A281-11CF-A5B7-0080C73AAC7E">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3969">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
</OBJECT>
-->
<%
Loop
If tRangeType = "Table" Then Response.Write "</TABLE>"
If tPageSize > 0 Then
If Not fHideRule Then Response.Write "<HR>"
If Not fHideNavBar Then
%>
<TABLE WIDTH=100% >
<TR>
<TD WIDTH=100% >
<P ALIGN=<%= tBarAlignment %> >
<FORM <%= "ACTION=""" & Request.ServerVariables("PATH_INFO") & 
stQueryString & """" %> METHOD="POST">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &lt;&lt;   ">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &lt;    ">
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="    &gt;   ">
<% If fSupportsBookmarks Then %>
<INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" 
VALUE="   &gt;&gt;   ">
<% End If %>
<% If Not fHideRequery Then %>
<INPUT TYPE="Submit" NAME="<% =tHeaderName & "_PagingMove" %>" VALUE=" ÂRequery ">
<% End If %>
</FORM>
</P>
</TD>
<TD VALIGN=MIDDLE ALIGN=RIGHT>
<FONT SIZE=2>
<%
If Not fHideNumber Then
If tPageSize > 1 Then
Response.Write "<NOBR>Page: " & Session(tHeaderName & "_AbsolutePage") & 
"</NOBR>"
Else
Response.Write "<NOBR>Record: " & Session(tHeaderName & "_AbsolutePage") & 
"</NOBR>"
End If
End If
%>
</FONT>
</TD>
</TR>
</TABLE>
<%
End If
End If
%>
<!--METADATA TYPE="DesignerControl" endspan-->
</BODY>
</HTML>

With the code in this listing, the ASP produces a web page similar to the one in Figure 21.9.

Figure 21.9.

Viewing the sales.

Case Study Review

You have now developed both the client and server portions of the application. I think you can see how these different components integrate to form a whole application. The HTML web pages in this example are used to display document and content information, supply links to other parts of the application, and provide the main default page for the application. The ASPs are used to display dynamic content that includes database integration. Given the powerful capabilities of Active Server Pages, you should use more of these pages in your future Web-based applications. I think you will see ASPs overtaking HTML pages in the not-too-distant future. The strength of ASPs comes from their ability to generate both HTML and client- and server-side script.

The lesson also demonstrates how to integrate database information into your application. The examples show you how to connect to the database, create the query, and then format the information in your web page. Try running the application now to get a feel for how the whole application works. Figures 21.10 through 21.14 illustrate the contents of the Publishers' Paradise application.

Figure 21.10.

The default page.

Figure 21.11.

The latest news.

Figure 21.12.

Choosing a report.

Figure 21.13.

Reviewing the titles.

Figure 21.14.

Reviewing the sales.

Summary

Today's lesson has demonstrated how the different components of a Visual InterDev project combine to form a Web-based application. The lesson should have given you the opportunity to apply the knowledge you gained over the past three weeks. How did you do? Were you able to recall the previous lessons you learned? You should now understand that the lessons of the past three weeks didn't focus on technology for technology's sake. Although the new and powerful technologies of the Web are technically cool, they have a more important mission as the critical tool to create the businesses of the future, as you learned in today's lesson.

The first part of the lesson gave you an overview of the Publishers' Paradise application. Next, the client components of the application were explained, and you were given a chance to test your knowledge by developing these components. Then the lesson proceeded to the server side of the equation. You were able to develop some ASP files and integrate them with a database to create a useful report. The final lesson for the day debriefed the case study and illustrated the pages in the application.

It will be interesting to see which technologies come out on top. Will it be ActiveX or Java applets? HTML or ASP? Whatever the outcome, you can count on Visual InterDev to support the winners!

Q&A

Q Are ASPs the wave of the future?

A
Yes, jump on the ASP bandwagon now! Seriously, ASP offers a robust alternative to strict HTML. ASPs are HTML and more because they can generate both client- and server-side script. As you would expect, Microsoft's web site includes a heavy dose of ASPs. In the future, you will see more and more sites and Web-based applications using the power of ASPs.

Q Can I mix ASPs and HTML web pages in my application?


A
Yes. Today's lesson demonstrated how HTML and ASP web pages can coexist in a Web-based application. The HTML was used for static web pages, and the ASPs were used for creating dynamic web pages that contained database integration.

Workshop

For the final workshop of this three-week journey, you should develop more web pages for the Publishers' Paradise application. You can use any of the tables in the Pubs database to support these pages. Try focusing on the concepts you might not understand as well as others. For example, you might want to create more images for the web pages, using the Image Composer to understand its capabilities. You also should practice using ASPs to deliver dynamic content from database tables. You can examine the tables and create added functions and features for the application, based on the information in the database.

Quiz

1. What design-time controls can be used to display multiple rows of data?

2.
What are the main differences between HTML and ASP files?

Quiz Answers

1. The Data Range Header and Data Range Footer controls.

2.
ASP files can generate HTML as well as scripting code for the client- and server-side portions of your application.

HOMEBACKFORWARDTOC