CHAPTER ELEVEN
Using Visual Basic .NET to
Create Web Applications
11- 2
Introduction
• We will look at applications where various parts
of the application run on the client as well as
servers.
• Visual Basic .NET has a powerful set of Web
Application tools.
• This is made possible using Microsoft’s
ASP.NET technology.
• Different Web architectures are examined.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11- 3
Introduction (cont.)
• An application is divided into three primary
functions:
– Presentation (GUI).
– Processing business logic.
– Data management.
• We will look at data validation.
• We will examine processing databases in the
Web Application context.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11- 4
Introduction (cont.)
• The chapter is ended with a project that
demonstrates how two or more Web pages can
communicate with each other by sharing data.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11- 5
Objectives
• Explain the various functions of a typical Web
Application.
• Explain what is meant by “client/server.”
• Explain how the client/server architecture can be
implemented in a number of different ways.
• Discuss the trade-offs associated with various
client/server architecture options.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11- 6
Objectives (cont.)
• Build a Web Application using the tools available
with Visual Basic .NET.
• Validate user data using the Validation controls
supported by Visual Basic .NET.
• Use the Web Form DataGrid control to display a
data set and to edit and update a database.
• Use XSLT documents to transform XML into
HTML on the server to then be displayed on the
client.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures
11- 7
• It is useful to break an application down into
three primary functions:
– Presentation involves how the application
interacts with the user.
– Business Logic involves rules that define how the
application handles data and processes them.
– Data Management involves databases and
software to management these databases.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures (cont.)
11- 8
• Architecture refers to how these three functions
are allocated to various computers.
• Client refers to the computer (or other intelligent
device) that the user is using.
• Server refers to another computer that is distinct
from the client and may be located anywhere in
the world.
– One server is referred to as two-tier architecture.
– More than two servers are referred to as n-tier
architecture.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures (cont.)
11- 9
• Presentation
– Option 1: Pure HTML.
• Any changes seen on the browser need to be sent
to the browser from the Web server.
• This option is unacceptable.
– Option 2: Script Within the Browser.
• Script are embedded within the HTML code sent
from the server to the browser.
• Creates very powerful user interfaces.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures (cont.)
• Business Logic
– Option 1: All Client.
• The application runs exclusively on the client
computer.
• Low bandwidth requirement.
• For medium and large organizations, problems
involve software installation and maintenance.
• Limited use.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1110
11.1 An Introduction to Functional Web
Architectures (cont.)
– Option 2: Embed Business Logic in a Web Page
Using Client-Side Scripting.
• Uses scripts that are interpreted in the browser.
• Scripts process business logic.
• Overcomes the installation and maintenance
problems of Option 1.
• Problem with user ability to view the scripts.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1111
11.1 An Introduction to Functional Web
Architectures (cont.)
– Option 3: Embed a Client-Side Component in the
Web Page.
• A software component, not script, is embedded in
the Web page and downloaded.
• Shares the advantages of Option 2.
• Overcomes the problem of script visibility.
• Requires large bandwidth.
• Security is a major problem.
• Microsoft uses a trusted application model.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1112
11.1 An Introduction to Functional Web
Architectures (cont.)
1113
– Option 4: Process Business Logic on the Server.
• Business logic is processed on the server.
• Communication between a Web server and client
browser.
• Implemented using Active Server Pages (ASP).
• Includes all the advantages of Option 3 without the
disadvantages of potential large bandwidth and
trusted application issues.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures (cont.)
1114
– Summary
• For business logic, a combination of Option 2 and
4 are most common.
• Option 2, client-side script, is used for data
validation and other nonproprietary processing.
• Option 4, server-side script, protects the privacy of
scripts.
• Option 4 is ideal for database support.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.1 An Introduction to Functional Web
Architectures (cont.)
• Data Management
– Option 1: Client-Side Only.
• Database and database management system are
both on the client.
• Speed is the advantage.
• No network issues.
• No issues with multiple users.
• Problems with database consistency, installation,
and maintenance.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1115
11.1 An Introduction to Functional Web
Architectures (cont.)
– Option 2: Server-Side Only.
• Database and DBMS are both on the server.
• Problem with communicating requests to the
server.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1116
11.1 An Introduction to Functional Web
Architectures (cont.)
– Option 3: Send a Set of Records to Client for
Further Processing.
• Similar to Option 2.
• Data from the server is processed directly by the
browser.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1117
11.1 An Introduction to Functional Web
Architectures (cont.)
• Summary
– Many different options for processing
presentation, business logic, and data
management functions.
– The choice of options is critical to application
success.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1118
11.2 ASP.NET Web Applications
1119
• Creating a Simple Web Application
– Visual Basic .NET provides a template to create a
new Web Application project.
– Use ASP.NET Web Application instead of
Windows Application.
– The extension for the Web form is “.aspx”.
– Complete Example 11.1, Simple Web Application,
in your textbook.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.2 ASP.NET Web Applications (cont.)
• Validating User Input
– Validator controls for Web Forms provide the
means for checking the contents of other
controls.
– Each input control can have zero or more
associated validators.
– Validators can perform on the client or server.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1120
11.2 ASP.NET Web Applications (cont.)
• Validation Controls for Web Forms
Type of Validation
Control to Use
Required entry
Comparison to a value
Range checking
Pattern matching
RequiredFieldValidator
CompareValidator
RangeValidator
RegularExpressionValidator
User-defined
CustomValidator
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1121
11.2 ASP.NET Web Applications (cont.)
1122
– Complete Example 11.2, Validating User Input, in
your textbook.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
11.3 Using Databases with Web
Applications
• Complete the examples listed below in your
textbook:
– Example 11.3 Using a DataGrid to Display Data
on a Web Form.
– Example 11.4 Editing Data Using a DataGrid
Component.
– Example 11.5 Using XML and XSL with Web
Form.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
1123
Chapter Summary
1124
• The three primary functions of any application
are presentation, business logic, and data
management.
• With Web Applications, presentation is almost
always managed on the client using a browser.
• The processing of business logic can be
handled on the client or server.
• Processing simple business rules is best done
with embedded script on the client.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.
Chapter Summary (cont.)
1125
• Complex and/or proprietary business logic
typically should be done on the server.
• Data management is typically handled on a
server.
• Visual Basic .NET supports Web Application
projects.
• The Web Form is the primary component in Web
Application projects.
McGraw Hill/Irwin
©2002 by The McGraw-Hill Companies, Inc. All
rights reserved.