Download - 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
![Page 1: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/1.jpg)
9-1
aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhfaslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
![Page 2: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/2.jpg)
Programming with Visual Web Developer
Chapter 9 9
McGraw-Hill © 2006 The McGraw-Hill Companies, Inc. All rights reserved.
![Page 3: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/3.jpg)
9-3
Objectives
Explain the functions of the server and the client in Web programming
Create a Web Form and run it in a browserDescribe the differences among the various types of
Web controls and the relationship of Web controls to controls used on Windows forms
Understand the event structure required for Web programs
Design a Web Form using tablesValidate Web input using the validator controlsDefine ASP, XML, WSDL, and SOAP
![Page 4: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/4.jpg)
9-4
Visual Basic and Web Programming
In VB.NET Web Forms are used to create the user interface for Web projects
Web Forms display as a document in a browserCreate documents that display on mobile
devices such as cell phones and personal digital assistants (PDAs)
![Page 5: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/5.jpg)
9-5
Client/Server Web Applications
Require a server and a clientServer sends the Web Pages to the ClientClient displays the Web Pages in Browser
![Page 6: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/6.jpg)
9-6
Web Servers
To develop Web applications use either aRemote Web Server
--OR--Local machine set up as a Web Server by installing
IIS before installing VB
![Page 7: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/7.jpg)
9-7
Web Clients
Browsers display pages written in hypertext markup language (HTML)Microsoft Internet ExplorerNetscape
Pages may also contain program logic in the form of Java AppletsScript
JavaScriptVBScriptJScript
![Page 8: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/8.jpg)
9-8
Web Pages
StatelessDoes not store any information about its contents from
one invocation to the nextTechniques for working around Stateless
Cookies stored on local machineSending state information to server as part of the page's
address, uniform resource locator (URL)
![Page 9: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/9.jpg)
9-9
ASP.NET
ASP.NET 2.0 is the latest Web programming technology from Microsoft
ASP.NET provides libraries, controls and programming support for programs that:Interact with the userMaintain state, render controlsDisplay data, and generate appropriate HTML
When using Web Forms in VB .NET you are using ASP.NET
Object-oriented event-drive Web applications can be created using VB and ASP.NET
![Page 10: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/10.jpg)
9-10
Visual Basic and ASP.NET
Each Web Form has two distinct piecesHTML and needed instructions to render the pageVB code
Web Form generates a file with an .aspx extension for HTML and .aspx.vb extension for the VB code
Visual Studio IDE automatically generates the HTMLHTML tags can be viewed and modified in the Visual
Studio editorVB code contains the program logic to respond to
events called the “code-behind” fileVB code is not compiled into an .exe file as it is for
Windows applications
![Page 11: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/11.jpg)
9-11
Types of Web Sites
Web applications are referred to as Web sites in VS 2005
There are four types of Web sitesFile System Web sitesIIS Web sitesFTP sitesRemote sites
![Page 12: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/12.jpg)
9-12
Creating a Web Site (1 of 2)
Select New Web Site from the File menu- in the New Web Site dialog box selections can be made for template, location, and language
A new web site automatically contains one Web page called Default.aspx
A second file, Default.aspx.vb, the code-behind file, holds the VB code for the project
![Page 13: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/13.jpg)
9-13
Creating New Web Site (2 of 2)
Begin a new Web project by entering the location and project name on the New Web Site dialog box.
![Page 14: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/14.jpg)
9-14
Web Forms in the Visual Studio IDE
As Web project opens, connection to Web Server is established
Web forms are based on a completely different class
Web forms have different Controls Properties, Methods, and EventsToolbar, Toolbox and lists of files in Solution
Explorer
![Page 15: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/15.jpg)
9-15
Visual Web Developer with New Web Site
![Page 16: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/16.jpg)
9-16
Viewing the HTML Code
Design and Sources tabs at bottom of the form in the Designer allow you to switch between the HTML code and VB code
Click on the Source tab to view the static HTML codeHTML creates the visual elements on the page and is
automatically generated
![Page 17: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/17.jpg)
9-17
Controls
Several types of controls are available for Web Forms and can be mixed on a single form
Very often used are the Standard (ASP.NET server controls)-provided by ASP.NET and the .NET frameworkWeb server controls don’t directly correspond to
HTML controls but are rendered differently for different browsers to achieve desired look/feel
![Page 18: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/18.jpg)
9-18
ToolBox Controls
Toolbox includes tabs for selecting control type
VS Designer adds a small green arrow in the upper-left corner of server controls
Server Control
Client-side HTML Control
![Page 19: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/19.jpg)
9-19
Event Handling
Events are written in the same way as for Windows controls
Events may actually occur onClientServer
Process of capturing an event, sending it to the server, and executing the required methods is all don automatically
Events of Web Forms are somewhat different than for Windows FormsExample: Page_Load versus Form_Load
![Page 20: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/20.jpg)
9-20
Files
Files in a Web application differ greatly from those in a Windows application
Two files make up the form:.aspx file
Holds specifications for the user interface.aspx.vb (“code-behind” file)
VB code written to respond to events
![Page 21: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/21.jpg)
9-21
Debugging
IDE does not automatically generate code necessary for debugging a Web application-debugging functions need to be added <compilation debug="true" />
If running without debugging enabled in the Web.config file an error message is received
There are two options:Run without debuggingAdd Web.config file
After creating the Web.config file breakpoints, single-step execution, and display the contents of variable and properties can be set
![Page 22: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/22.jpg)
9-22
Add Web.config File
![Page 23: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/23.jpg)
9-23
Testing In Other Browsers
By default, Web projects are tested in Microsoft Internet Explorer
To test in another browserRight-click on the project nameSelect Browse With
![Page 24: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/24.jpg)
9-24
Laying Out Web Forms
Factors that will effect the layout of pageBrowsersScreen SizesScreen ResolutionsWindow Sizes
ASP.NET generates appropriate HTML to render the page in various browsers but cannot be aware of the screen size, resolution, or window size on the target machine
![Page 25: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/25.jpg)
9-25
Using Tables for Layout
HTML Tables contain rows and columns
Add controls and text to the table cells to align the columns
Table is an HTML control, requiring no server-side programming
![Page 26: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/26.jpg)
9-26
Entering Controls or Text in a Table
Controls can be added to a table cell or type text in a cell during design time
Add a label and give it an ID to be able to refer to the text in a cell at run time –OR—
Type text directly into the cell
![Page 27: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/27.jpg)
9-27
Including Images on Web Pages
Use the Image control to add graphics to a Web pageConcept is similar to the PictureBox control on Windows
Forms but the graphic file is connected differently due to the nature of the Web applications
Each Image control has an ImageUrl property that specifies the location of the graphic file
Placing an image on a Web page the graphic should first be copied into the Web site folder
Image controls can be added to a cell in a table or directly on a Web page
![Page 28: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/28.jpg)
9-28
Table and Image
Place images, text, andcontrols where wanting themby using a table.
![Page 29: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/29.jpg)
9-29
Navigating Web Pages
Add a HyperLink to allow user to navigate to another site or page
Enter a Text property for the text to display for the user
Enter a NavigateUrl property to specify the URL to which to navigate; the Select URL dialog box displays
Select the page from a list
If wanting to navigate to another Web site, type the web address as the NavigateUrl property value
![Page 30: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/30.jpg)
9-30
Select URL dialog box
Select the page to which tonavigate for a HyperLinkcontrol from the Select URLdialog box.
![Page 31: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/31.jpg)
9-31
Adding a Second Web Page
To add a new Web Form to a Web site, select Web Form in the Add New Item dialog box. Make sure to choose Visual Basicfor the language and select Place code in separate file
![Page 32: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/32.jpg)
9-32
Using the Validator Controls
ASP.NET provides several controls that can automatically validate input data
Steps for usingAdd a validator control – attach it to an input control and
set the error messageAt run time, when data is input, the error message
displays if the validation rule is violatedValidator controls run on the client side
![Page 33: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/33.jpg)
9-33
Maintaining State
Must take steps to maintain values of variables and controls on page
Set EnableViewState to True (default) so control contents reappear for each postback
Local variables in a Web application are re-created each time the procedure begins
Store value of module-level variables in controls to hold their values during postback
Use IsPostBack property to control actions on postback
![Page 34: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/34.jpg)
9-34
Checking for Postback
When an ASP.NET application loads, the Page-Load event occurs—the page is reloaded for each “round-trip” to the server (each postback)
The Page-Load event occurs many times in a Web application
The page’s IsPostBack property is set to False for the initial page load and to True for all page loads after the first
Check for IsPostBack = True to make sure that actions are only performed on postbacks
![Page 35: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/35.jpg)
9-35
Managing Web Projects
Moving and renaming Web project is easy when using File Systems Web sites opposed to IIS sites
Make sure the project is closed so that the project folder can be renamed and then it can be moved or copied to different locations or computers
![Page 36: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/36.jpg)
9-36
Using the Copy Web Site Tool
Can copy an entire Web site from one location to another on the same computer, or to another computer on a network, or to a remote site
Can copy the Web site to a remote server where it can be accessed by multiple users
![Page 37: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/37.jpg)
9-37
Some Web Acronyms (1 of 2)
XML Extensible Markup Language. This popular tag-based notation isused to define data and their format and transmit the data overthe Web. XML is entirely text based, does not follow any onemanufacturer’s specifications, and can pass through firewalls
SOAP Simple Object Access Protocol. An XML-based protocol for exchanging component information among distributed systems of many different types. Since it is based on XML, its messages can pass through network
![Page 38: 9-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf](https://reader035.vdocuments.us/reader035/viewer/2022081519/56649e0c5503460f94af4a83/html5/thumbnails/38.jpg)
9-38
Some Web Acronyms (2 of 2)
HTTP HyperText Transfer Protocol. The protocol used to send and receive Web pages over the Internet using standardized request and response messages
Web Service Code in classes used to provide middle-tier services over the Internet
WSDL Web Services Description Language. An XML document using specific syntax that defines how a Web service behaves and how clients interact with the service