Microsoft VB 2005: Reloaded,

mewstennisSoftware and s/w Development

Nov 4, 2013 (3 years and 5 months ago)

46 views

Microsoft VB 2005: Reloaded,
Advanced


Chapter 9

An Introduction to ASP.NET

Microsoft VB 2005: Reloaded, Advanced

2

Objectives


Explain concepts related to Web pages, client/server
architecture, and multi
-
tier architecture


Explain the concepts of client
-
side scripting and
server
-
side scripting


Create a Web site using ASP.NET


Use several kinds of Web controls in a Web form


Create a layout for a Web form using a table

Microsoft VB 2005: Reloaded, Advanced

3

Introduction to Web Applications


Objective


Understand some basics about creating Web pages
and about client/server architecture

Microsoft VB 2005: Reloaded, Advanced

4

Creating Web Pages


Web page


Text file written using
Hypertext Markup Language
(HTML)


With a file extension of .htm or .html


Contains several
HTML elements


Sections within a Web page that define the page’s
structure, content, and functionality


Elements consist of:


Start tag


Element content


End tag

Microsoft VB 2005: Reloaded, Advanced

5

Creating Web Pages (continued)

Microsoft VB 2005: Reloaded, Advanced

6

Creating Web Pages (continued)

Microsoft VB 2005: Reloaded, Advanced

7

Creating Web Pages (continued)


An Internet browser is used to open an HTML file


The browser downloads the HTML file


Reads it line by line


Interprets the HTML tags


Displays the page content accordingly

Microsoft VB 2005: Reloaded, Advanced

8

Creating Web Pages (continued)

Microsoft VB 2005: Reloaded, Advanced

9

Client/Server Architecture for Web
Applications


Client


Web browser on the user’s computer


Server


Web server


Computer with special software that stores Web pages
and is connected to the Internet


HTTP (
Hypertext Transfer Protocol
)


Set of rules for exchanging files on the Web


Domain name


Text name corresponding to the unique numeric IP
address of a computer on the Internet

Microsoft VB 2005: Reloaded, Advanced

10

Client/Server Architecture for Web
Applications (continued)

Microsoft VB 2005: Reloaded, Advanced

11

Client/Server Architecture for Web
Applications (continued)


HTTP transaction


The Web client requesting a file and the Web server
responding to the request using HTTP

Microsoft VB 2005: Reloaded, Advanced

12

Client/Server Architecture for Web
Applications (continued)

Microsoft VB 2005: Reloaded, Advanced

13

Multi
-
tier Architecture for Web
Applications


Web application


Application that uses a Web browser as the user
interface


Multi
-
tier architecture


Also called
n
-
tier architecture


Places different basic components of the application
on
n
distinct software layers or tiers


Three
-
tier architecture components


Presentation tier, logic tier, and data tier

Microsoft VB 2005: Reloaded, Advanced

14

Multi
-
tier Architecture for Web
Applications (continued)

Microsoft VB 2005: Reloaded, Advanced

15

Scripting and ASP.NET


Programmer creates computer programs for the
presentation and logic tiers of a multi
-
tier application


Presentation tier involves creating forms that contain
components


Logic tier involves writing program code to process
the information


Obtained from the presentation tier and the data tier


Web applications


Use a Web browser as the user interface

Microsoft VB 2005: Reloaded, Advanced

16

Client
-
Side Scripting


Web pages consisting only of HTML code are very
static


Real Web applications require Web pages with
processing capabilities


Scripting language


Language that can be used in a Web page


Examples: JavaScript and VBScript


Script


Set of instructions interpreted by another program
rather than the computer processor

Microsoft VB 2005: Reloaded, Advanced

17

Client
-
Side Scripting (continued)


Script
(continued)


Embedded in a Web page using the
<script>

tag


Scripting code can be embedded in a Web page


Or placed in a file referenced by the Web page


Client
-
side scripting


Downloading scripts to the browser for execution


Makes Web pages dynamic and interactive


Disadvantage


Longer download times


Using scripting codes is insecure

Microsoft VB 2005: Reloaded, Advanced

18

Client
-
Side Scripting (continued)

Microsoft VB 2005: Reloaded, Advanced

19

Server
-
Side Scripting


Applications involving databases require server
-
side
scripting


Server
-
side scripting


Code is executed on the server instead of the client


Examples: PHP, ASP, and JSP


Advantages


Processing is faster


Downloading is quicker


User is allowed to see only the resulting HTML code

Microsoft VB 2005: Reloaded, Advanced

20

Server
-
Side Scripting (continued)

Microsoft VB 2005: Reloaded, Advanced

21

What is ASP.NET?


ASP.NET


Latest Microsoft technology for developing highly
interactive Web applications


Serves same purpose as classic ASP


ASP.NET file has a .aspx file extension


And is called a Web form instead of a Web page


Can contain ordinary HTML controls and special
ASP.NET (Web) server controls


Web server controls


Objects that have many properties and can call
complex event procedures

Microsoft VB 2005: Reloaded, Advanced

22

What is ASP.NET? (continued)


ASP.NET advantages


Part of the .NET Framework


Supports a more structured approach to server
-
side
scripting


Allows the programmer to create controls using the
.NET event
-
driven model


ASP.NET code is compiled rather than interpreted


Supports ADO.NET

Microsoft VB 2005: Reloaded, Advanced

23

Creating a Web Site With ASP.NET


Objective


Create an ASP.NET Web site and add some simple
content to a Web form

Microsoft VB 2005: Reloaded, Advanced

24

Creating an ASP.NET Web Site

Microsoft VB 2005: Reloaded, Advanced

25

Creating an ASP.NET Web Site
(continued)

Microsoft VB 2005: Reloaded, Advanced

26

Creating an ASP.NET Web Site
(continued)

Microsoft VB 2005: Reloaded, Advanced

27

Creating an ASP.NET Web Site
(continued)

Microsoft VB 2005: Reloaded, Advanced

28

Exploring an ASP.NET Web Form


The Default.aspx.vb file is a code
-
behind file


Code
-
behind file


VB class containing event procedures that
accompany controls placed on ASP.NET Web form


Document type declaration


Begins with the keyword
DOCTYPE
followed by:


Name of the base element of the document


Specification of the markup language to be used

Microsoft VB 2005: Reloaded, Advanced

29

Exploring an ASP.NET Web Form
(continued)


XML namespace


Collection of names, identified by a URI reference


Used in XML documents as element types and attribute
names


Simple method for establishing unique element types
and attribute names in an XML document


form

attribute
runat


ASP.NET technique for directing this HTML element
to be executed on the server

Microsoft VB 2005: Reloaded, Advanced

30

Adding Content to a Web Form

Microsoft VB 2005: Reloaded, Advanced

31

Adding Content to a Web Form
(continued)

Microsoft VB 2005: Reloaded, Advanced

32

Adding Content to a Web Form
(continued)

Microsoft VB 2005: Reloaded, Advanced

33

Adding Content to a Web Form
(continued)

Microsoft VB 2005: Reloaded, Advanced

34

Adding Content to a Web Form
(continued)

Microsoft VB 2005: Reloaded, Advanced

35

Adding an Event Procedure to a
Control


Web sites are much more interesting and useful
when they are interactive


Accomplish this through event
-
driven programming


Microsoft VB 2005: Reloaded, Advanced

36

Adding an Event Procedure to a
Control (continued)

Microsoft VB 2005: Reloaded, Advanced

37

Adding an Event Procedure to a
Control (continued)

Microsoft VB 2005: Reloaded, Advanced

38

Adding an Event Procedure to a
Control (continued)

Microsoft VB 2005: Reloaded, Advanced

39

Adding an Event Procedure to a
Control (continued)

Microsoft VB 2005: Reloaded, Advanced

40

Adding a Web Form to a Site


Hyperlink


Contraction of “hypertext link”


A graphic or text in a Web page that, when clicked,
opens a new Web page or jumps to a new location in
the current page

Microsoft VB 2005: Reloaded, Advanced

41

Adding a Web Form to a Site
(continued)

Microsoft VB 2005: Reloaded, Advanced

42

Adding a Web Form to a Site
(continued)

Microsoft VB 2005: Reloaded, Advanced

43

Using Web Server Controls


Objective


Learn more about how to use Web server controls

Microsoft VB 2005: Reloaded, Advanced

44

Overview of Web Server Controls


Web server controls in ASP.NET are similar to
typical Windows Forms


Defined by classes and have many of the same
properties


Instead of the
Name

property, Web controls use the
ID

property


A Web form typically contains a variety of controls


Each of these controls can have its own event
procedure created in the code
-
behind file

Microsoft VB 2005: Reloaded, Advanced

45

Overview of Web Server Controls
(continued)


AutoPostBack

property


Affects the performance of a Web application


If
AutoPostBack

is
True


Whenever the contents of an individual control change


The entire Web form is automatically posted back to
the Web server for processing


If
AutoPostBack

is
False


The Web form is posted back to the Web server only
when the user clicks a Submit button

Microsoft VB 2005: Reloaded, Advanced

46

Types of Web Controls


Label

control


Displays text on a Web form


Textbox

control


Allows for user input


Button

control


Submit button


Posts the Web form to the Web server for processing


Command button


HyperLink

control


Creates a hyperlink in the Web form

Microsoft VB 2005: Reloaded, Advanced

47

Types of Web Controls (continued)


ImageButton

control


Behaves like a standard
Button

control


Uses a graphic stored in the Web site instead of the
standard
Button

style


LinkButton

control


Behaves like a standard
Button


Uses plain text instead of the standard
Button

shape


ListBox

control


Similar to the Windows Forms
ListBox

control

Microsoft VB 2005: Reloaded, Advanced

48

Types of Web Controls (continued)

Microsoft VB 2005: Reloaded, Advanced

49

Types of Web Controls (continued)

Microsoft VB 2005: Reloaded, Advanced

50

Types of Web Controls (continued)

Microsoft VB 2005: Reloaded, Advanced

51

Types of Web Controls (continued)

Microsoft VB 2005: Reloaded, Advanced

52

Using Tables for Form Layout


HTML table control: better way of organizing
controls on a page

Microsoft VB 2005: Reloaded, Advanced

53

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

54

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

55

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

56

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

57

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

58

Using Tables for Form Layout
(continued)


Modified SportsWebSite


Using tables for the layout of the controls in the
Sports.aspx Web form

Microsoft VB 2005: Reloaded, Advanced

59

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

60

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

61

Using Tables for Form Layout
(continued)

Microsoft VB 2005: Reloaded, Advanced

62

Summary


A Web page is a text file written in Hypertext
Markup Language (HTML)


A simple Web page contains several HTML
elements


An Internet browser is used to open an HTML file


A Web application can use a simple client/server
architecture or a multi
-
tier architecture


Also called
n
-
tier architecture


JavaScript is a scripting language, a programming
language that can be used within a Web page

Microsoft VB 2005: Reloaded, Advanced

63

Summary (continued)


Client
-
side scripting versus server
-
side scripting


ASP.NET is the latest Microsoft technology for
developing highly interactive Web applications


A code
-
behind file is a Visual Basic class
containing the event procedures


That accompany controls placed on an ASP.NET
Web form


A Web form can contain a variety of controls


A better way of organizing controls on a page is by
using the HTML table control