After studying this chapter you should be able to Explain the various functions of a typical web application, explain what is meant by the term clientserver and how the clientserver architecture can be implemented in a number of different ways, discuss the tradeoffs associated with various clientserver architecture options,...
Trang 1Using Visual Basic NET to Create Web Applications
Trang 2• We will look at applications where various parts
of the application run on the client as well as
Trang 3• 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
Trang 4Introduction (cont.)
• The chapter is ended with a project that
demonstrates how two or more Web pages can
communicate with each other by sharing data
Trang 5• 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
Trang 6Objectives (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
Trang 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
Trang 811.1 An Introduction to Functional Web
Architectures (cont.)
• 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.
Trang 9Architectures (cont.)
• 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.
Trang 1011.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.
Trang 11Architectures (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.
Trang 1211.1 An Introduction to Functional Web
• 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.
Trang 13Architectures (cont.)
– 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.
Trang 1411.1 An Introduction to Functional Web
Trang 15Architectures (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.
Trang 1611.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.
Trang 1811.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.
Trang 19• 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,
Trang 2011.2 ASP.NET Web Applications (cont.)
• Validating User Input
– Validator controls for Web Forms provide the
means for checking the contents of other
Trang 21• Validation Controls for Web Forms
Type of Validation Control to Use
Required entry RequiredFieldValidator
Comparison to a value CompareValidator
Range checking RangeValidator
Pattern matching RegularExpressionValidator
User-defined CustomValidator
Trang 2211.2 ASP.NET Web Applications (cont.)
– Complete Example 11.2, Validating User Input, in
your textbook.
Trang 24Chapter Summary
• 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
Trang 25• Complex and/or proprietary business logic
typically should be done on the server
• Data management is typically handled on a
Trang 26Chapter Summary (cont.)
• Background HTML code is created automatically
by Visual Basic NET
• Web Forms include a number of Validator
controls that can be added to the project
• Validation is automatically done in the browser
on the client by script
• The DataGrid control for the Web Form supports
the display of datasets
Trang 27• XML processing is available to the Web Form.
• Visual Basic NET provides methods to maintain
a session within ASP.NET