Module 7: Building Web Applications
Module 7: Building Web Applications
Applications
Contents
Overview 1
Introduction to ASP.NET 2
Creating Web Form Applications 16
Demonstration: Creating Web Forms 30
Lab 7.1: Creating the Customer
Logon Web Forms 31
Building Web Services 42
Demonstration: Creating a Web Service 50
Using Web Services 51
Demonstration: Using a Web Service 57
Multimedia: How Web Services Work 58
Lab 7.2: Creating and Using the
CustomerService Web Service 60
Review 71
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part
of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted
in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or
for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
Microsoft, MS-DOS, Windows, Windows NT, ActiveX, BizTalk, FrontPage, IntelliSense, JScript,
Microsoft Press, Outlook, PowerPoint, Visio, Visual Basic, Visual C++, Visual C#, Visual
InterDev, Visual J#, Visual SourceSafe, Visual Studio, and Windows Media are either registered
trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Module 7: Building Web Applications iii
Instructor Notes
Presentation: This module provides students with the knowledge needed to create Web-based
120 Minutes applications.
Labs: In the first lab, students will create several Web Forms for logging on or
105 Minutes registering as a customer of the Cargo system. In the second lab, students will
create a Web Service that provides information about customers and allows the
addition of new customers to the system. The labs use predefined classes that
replicate data storage and retrieval.
After completing this module, students will be able to:
Explain and take advantage of the benefits of ASP.NET and its various
libraries in application development.
Create Web Form applications.
Use HTML server controls and Web server controls.
Create Web Services.
Use Web Services from a browser or from another client application.
Required Materials
To teach this module, you need the following materials:
Microsoft® PowerPoint® file 2373B_07.ppt
Module 7, “Building Web Applications”
Lab 7.1, Creating the Customer LogOn Web Forms
Lab 7.2, Creating and Using the CustomerService Web Service
Multimedia presentation, How Web Services Work, file 2373_How Web
Services Work.htm on the Student Materials compact disc
Preparation Tasks
To prepare for this module, you should:
Read all of the materials for this module.
Read the instructor notes and the margin notes for the module.
Practice the demonstrations.
Complete the labs.
iv Module 7: Building Web Applications
Demonstrations
This section provides demonstration procedures that will not fit in the margin
notes or are not appropriate for the student notes.
These demonstrations show the creation of simple Web Forms and simple Web
Services. If students have previous experience with ASP.NET Beta 1, consider
using validation controls in the Web Forms demonstration, and analyze the
client-side proxy files generated in the Using a Web Service demonstration.
6. To describe the purpose of each TextBox, add Normal style text above each
box, as shown in the following table.
TextBox Describing text
3. To display the new HTML description page, rebuild the project and view
QueryUsers.asmx in the browser as before, pointing out the new
descriptions.
4. Close Visual Studio .NET.
Module 7: Building Web Applications vii
Multimedia Presentation
This section provides multimedia presentation procedures that do not fit in the
margin notes or are not appropriate for the student notes.
Module Strategy
Use the following strategy to present this module:
Introduction to ASP.NET
This lesson introduces ASP.NET and shows some of the benefits over
Active Server Pages (ASP). Emphasize that this is primarily an overview
lesson; most of these topics are addressed in more detail throughout the
module.
For more in-depth information about ASP.NET, refer students to Course
2063A, Introduction to ASP.NET.
Creating Web Form Applications
This lesson shows how to create Web Forms applications. Students examine
the structure of a Web Form, including some of the important directives that
are used within the page definition. Compare HTML controls to Web server
controls, and highlight some individual controls for discussion, such as the
validation controls and the AdRotator control. Finally, introduce students
to event handling for ASP.NET server controls.
Building Web Services
This lesson describes the open standards and protocols that enable Web
Services, in addition to how to create Web Services and their methods by
using the WebMethod attribute. The student notes show how to include
method and Web Service descriptions within these attributes. Point these
lessons out to students. Use the instructor-led demonstration to show
students how to create a simple Web Service and its discovery document.
Using Web Services
In this lesson, you examine how to use a Web Service from a client,
including the process of discovery and the exploration of service
descriptions. Explain to students how they can access this information from
a browser and from a rich client such as Visual Basic .NET. Use the
demonstration and animation at the end of the module to give students
examples of possible scenarios for Web Services, and elicit suggestions for
other Web Services from the students.
Module 7: Building Web Applications 1
Overview
Topic Objective
To provide an overview of
the module topics and
objectives. Introduction to ASP.NET
Lead-in Creating Web Form Applications
In this module, you will learn
about building Web Building Web Services
applications with
Visual Basic .NET. Using Web Services
Introduction to ASP.NET
Topic Objective
To provide an overview of
the topics covered in this
lesson. Overview of ASP.NET
Lead-in Using Response and Request Objects
ASP.NET introduces many
improvements upon Maintaining Client-Side State
traditional approaches to
Web development. Maintaining Server-Side State
Managing an ASP.NET Application
Overview of ASP.NET Security
Using Global Events with Global.asax
Overview of ASP.NET
Topic Objective Code behind development
To discuss the key features
provided by ASP.NET. Intuitive approach to development similar to Windows Forms
Lead-in Code can be compiled using any .NET-compatible language
ASP.NET introduces many
Significant performance improvement
significant enhancements to
ASP. ASP.NET pages run side-by-side with ASP pages
Files with the .aspx extension run side-by-side with current
ASP applications on IIS
Automatic support for multiple browsers
Rich DHTML, HTML 3.2, and small devices
ASP.NET namespaces provide rich functionality
Built-in support for Web Services
Response.Write(ViewState("TempData"))
When the page is sent to the browser, a hidden variable is included, as shown in
the following example:
<input type="hidden" name="__VIEWSTATE" value="dO…NnU=" />
Example
The following example shows how to store the start time of the application and
then displays the information at a later stage:
Application("App_StartTime") = Now
...
Response.Write("Application Started: " & _
Application("App_StartTime"))
Module 7: Building Web Applications 9
Example
You can use the intrinsic Session object to access this state information. The
following example shows how to use session state to store a start time that can
be retrieved at a later stage during the user’s session:
Session("Session_StartTime") = Now
...
Response.Write("Session started: " & _
Session("Session_StartTime"))
Note For more information about configuring session state, search for
“web.config” in the Microsoft Visual Studio® .NET documentation.
10 Module 7: Building Web Applications
Note For more information about the different types of authentication, see
Designing Secure Web-Based Applications for Microsoft Windows 2000, by
Michael Howard, Microsoft Press®.
Application-Level Events
ASP.NET provides several events to initialize state at the application level,
including the following:
Application_Start
This event is activated when the first user attempts to gain access to access
your Web application. Any subsequent requests will not activate this event
even if multiple instances of the Global class have been instantiated. This
event is particularly useful for initializing application-state information.
Application_BeginRequest
This event is activated whenever a request for a URL is received from a
client application.
Application_EndRequest
This event is activated whenever a request for a URL has been completed.
Application_End
This event is activated when the last instance of the Global class is
destroyed so that any final resources can be cleaned up.
Module 7: Building Web Applications 15
Session-Level Events
ASP.NET also provides session-level events, including the following:
Session_Start
This event is activated at the beginning of a new client session and is useful
for initializing session-state information.
Session_End
This event is activated when a client session ends after a period of inactivity
or if the Session.Abandon method is explicitly called as part of your
application code.
Example
The following example shows how you could use these events in conjunction
with state management objects to initialize stateful data:
Sub Application_Start(ByVal sender As Object, _
ByVal e As EventArgs)
'Initialize the application-level counter
Application("SessionCounter") = 0
End Sub
<tags> code
Logon.aspx Logon.aspx.vb
Alternatively, developers
can include both code and
The .aspx File
HTML tags within a single The .aspx file contains definitions for the visual elements of the Web Form,
.aspx file by using the such as the HTML tags, Web controls, client-side script, and static text. This
<script> tag. This approach file also includes any ASP.NET directives, such as links to the code-behind
provides less separation module that contains the logic and event-handling code of the Web Form.
between the code and tags,
but does not require a DLL You can use the Web Forms Designer in Design view to create a page by using
file to be built and deployed drag-and-drop techniques. You can use the HTML view to edit the HTML tags.
with the application. Microsoft IntelliSense® is provided in this view to increase the efficiency and
accuracy of creating HTML tag expressions.
18 Module 7: Building Web Applications
The code generated in the code-behind file looks very similar to the code
generated in Windows Forms. Note the following when using the code-behind
file:
It contains variable declarations.
The code contains variable declarations for the visible controls so they can
be accessed programmatically within your procedures.
It contains variable events.
As the control variables are declared using the WithEvents modifier, you
can use the control events to execute user interface code to handle events
like submitting information to a database or linking to another page.
It automatically compiles with your application.
The code in this file is automatically compiled into your dynamic-link
library (DLL) when you build the application.
Module 7: Building Web Applications 19
You can set other properties of the HTML control by using the Attributes
collection property of the control. This type of property setting is considered
weakly typed because the collection only stores and retrieves String values, as
shown in the following example:
HTMLTable1.Attributes("bgColor") = "Green" 'Weakly typed
To specify the programmatic accessor that identifies the control in the server
code, use the ID attribute. To set the initial display value of the text field, use
the VALUE attribute.
<A> HTMLAnchor
<IMG> HTMLImage
<FORM> HTMLForm
<TABLE> HTMLTable
<TR> HTMLTableRow
<TD> HTMLTableCell
<SELECT> HTMLSelect
<TEXTAREA> HTMLTextArea
<BUTTON> HTMLButton
<INPUT TYPE=TEXT> HTMLInputText
< INPUT TYPE=FILE> HTMLInputFile
< INPUT TYPE=SUBMIT> HTMLInputButton
< INPUT TYPE=BUTTON> HTMLInputButton
< INPUT TYPE=RESET> HTMLInputButton
< INPUT TYPE=HIDDEN> HTMLInputHidden
Module 7: Building Web Applications 21
Rich functionality
Example: Calendar or RadioButtonList control
Rich functionality
Web server controls include enhanced versions of traditional HTML form
controls such as Button and TextBox, as well as complex controls such as
Calendar, DataGrid, and AdRotator (advertisement rotator). These
controls do not correspond directly to HTML elements or attributes.
Module 7: Building Web Applications 23
The following example shows the information required in the XML file to
rotate the advertisements:
<Advertisements>
<Ad>
<ImageUrl>images/graphic1.gif</ImageUrl>
<NavigateUrl>http://www.example1.microsoft.com</NavigateUrl>
<AlternateText>
Click here for products page 1
</AlternateText>
<Keyword>Products 1</Keyword>
<Impressions>80</Impressions>
</Ad>
<Ad>
<ImageUrl>images/graphic2.gif</ImageUrl>
<NavigateUrl>http://www.example2.microsoft.com</NavigateUrl>
<AlternateText>
Click here for products page 2
</AlternateText>
<Keyword>Products 2</Keyword>
<Impressions>80</Impressions>
</Ad>
</Advertisements>
Example
<form name="WebForm1" method="post" action="WebForm1.aspx"
id="WebForm1">
<table id="RadioButtonList1" border="0">
<tr><td>
<input type="radio" id="RadioButtonList1_0" value="One"
name="RadioButtonList1" />
<label for="RadioButtonList1_0">One</label>
</td></tr>
<tr><td>
<input type="radio" id="RadioButtonList1_1" value="Two"
name="RadioButtonList1" />
<label for="RadioButtonList1_1">Two</label>
</td></tr>
</table>
</form>
Note For information about creating Web Form controls, see Module 9,
“Developing Components in Visual Basic .NET,” in Course 2373B,
Programming with Microsoft Visual Basic .NET.
Module 7: Building Web Applications 27
Handling Events
Topic Objective
To explain how to handle Event handlers contain code for user interactions
events in Web Forms.
Page events: Init, Load, PreRender, UnLoad
Lead-in
Handling events in Web Private
Private Sub
Sub Page_Load(ByVal
Page_Load(ByVal Sender
Sender As
As System.Object,
System.Object, __
Forms is similar to ByVal
ByVal e As System.EventArgs) Handles MyBase.Load
e As System.EventArgs) Handles MyBase.Load
traditional Visual Basic If
If Not
Not IsPostBack
IsPostBack Then
Then 'IsPostBack
'IsPostBack is
is also
also available
available via
via 'Me'
'Me'
event handling. 'Perform action first time page is displayed
'Perform action first time page is displayed
End
End If
If
End Sub
End Sub
Page Events
Every Web Form inherits from the Page class, which provides several useful
events indirectly from other inherited classes such as the Control and
TemplateControl classes. Several of these events are included in the following
list, in the order in which they occur when a user accesses a page:
Init
This event occurs as the first step in the page lifecycle, when the page is
initialized. You use this event to initialize local variables. Do not use this
event to access view state information or controls on the page, because they
may not be created or accessible at this point.
Load
This event occurs after the Init event and before the PreRender events are
raised. You can use this event to view state information or access controls.
PreRender
This event occurs when the page is about to render its contents to the Web
browser. Use it to perform any pre-rendering steps before the view state is
saved.
Unload
This event occurs when the page is unloaded, after rending has occurred.
Use it for removing any resources created throughout the request.
28 Module 7: Building Web Applications
Control Events
Server controls are based on the WebControl class, which is based on the
System.Web.UI.Control class. The Page class is also based indirectly on the
System.Web.UI.Control class, through the TemplateControl class. Therefore,
server controls share the events described in the preceding Page Events section.
Individual controls also add their own events to the object model to allow easier
interaction with the user. Examples include the simple Click event for the
Button class, the TextChanged event for the TextBox class, and the
SelectedIndexChanged event for the ListControl class.
Some controls post their events to the server immediately, such as the Click
Delivery Tip event of the Button class. Other controls, such as the TextChanged event of
Discuss when events are
raised by explaining the
the TextBox class, may only register their events when other means are used to
AutoPostBack property, as post events to the server. These events are stored and then raised sequentially to
shown in the example in the the server code when the post event is triggered. You can alter this behavior by
notes. setting the AutoPostBack property of the control to True. In this way, you can
raise events immediately regardless of the default behavior. In the case of a
TextBox control, this means the event will be posted every time the text value
is modified and the control loses focus.
Module 7: Building Web Applications 29
Important Using the AutoPostBack property for multiple controls on the same
form will slow down the performance of the application because of the need for
multiple trips to the server.
30 Module 7: Building Web Applications
Prerequisites
Before working on this lab, you must be familiar with creating Web Forms in
Visual Basic .NET.
Scenario
In this lab, you will create Web Forms that register and logon customers for the
Cargo system.
The WebCustomer class is provided for you to use as a basis for your Web
application. It provides some existing customer details to test your application
and allows you to add new customers. Any customer details added are only
valid for a single test session because they are not persisted to disk at this time.
Exercise 1
Creating the DefaultPage Web Form
In this exercise, you will create a Web Application and its default menu page.
5. From the Web Forms toolbox, insert the following controls, separated by
line breaks.
Control Property Value
Exercise 2
Creating the NewCustomer Web Form
In this exercise, you will create a Web Form to allow new customers to register.
4. From the Web Forms toolbox, insert the following controls, and set their
properties as shown in the following table.
Control Property Value
(continued)
Control Property Value
TextMode Password
RegularExpressionValidator (ID) revPassword
ErrorMessage Your password
must be at least 4
characters long
ControlToValidate txtPassword
ValidationExpression Click the browse
button and select
(Custom) from the
list, entering the
following value
\w{4,}
Display Dynamic
RequiredFieldValidator (ID) rfvPassword
ErrorMessage Please enter a
password
ControlToValidate txtPassword
Display Dynamic
TextBox (ID) txtConfirm
TextMode Password
CompareValidator (ID) cvConfirm
ErrorMessage Passwords do not
match
ControlToValidate txtConfirm
ControlToCompare txtPassword
Display Dynamic
RequiredFieldValidator (ID) rfvConfirm
ErrorMessage Please confirm the
password
ControlToValidate txtConfirm
Display Dynamic
Button (ID) btnSubmit
Text Submit
Module 7: Building Web Applications 35
5. Create your Web Form so that it looks like the following illustration.
Response.Redirect("Welcome.aspx")
Exercise 3
Creating the LogOn Web Form
In this exercise, you will create the LogOn Web Form for existing customers.
4. From the Web Forms toolbox, insert the following controls, separated by
line breaks, arranging them with their related text values.
Control Property Value
(continued)
Control Property Value
6. Double-click the btnSubmit button, and add the following code to the
btnSubmit_Click event handler:
Dim existingCustomer As New WebCustomer( )
lblNotFound.Visible = False
Try
existingCustomer.LogOn(txtEmail.Text, txtPassword.Text)
Session("User_FullName") = existingCustomer.FullName
Response.Redirect("Welcome.aspx")
Catch ex As Exception
lblNotFound.Text = ex.Message
lblNotFound.Visible = True
Finally
existingCustomer = Nothing
End Try
Exercise 4
Creating the Welcome Web Form
In this exercise, you will create the Welcome Web Form that customers see
after they are logged on to the system.
4. Open the Code Editor for Welcome.aspx.vb, and locate the Page_Load
event handler. Enter the following code:
lblWelcome.Text = "Welcome " & _
Session("User_FullName")
E-mail [email protected]
Password password
If Time Permits
Using Cookies
In this optional exercise, you will use cookies to store and retrieve information
about a customer.
(ID) chkSave
Checked True
Text Save details
3. Open the Code Editor for LogOn.aspx.vb, and locate the btnSubmit_Click
event handler. Add the following code after the call to the
existingCustomer.LogOn method:
If chkSave.Checked = True Then
Response.Cookies("User_FullName").Value = _
existingCustomer.FullName
Response.Cookies("User_FullName").Expires = _
Now.AddMonths(1)
End If
E-mail [email protected]
Password password
Save details Checked
You can add a description for each method by specifying the Description
argument of the WebMethod attribute, as shown in the following example:
<WebMethod(Description:="This method performs an action")> _
Public Sub PerformAction( )
...
End Function
Tip If you already have components that you want to convert to Web Services,
you can simply create a wrapper Web Service module that calls your
preexisting components and returns any results.
Module 7: Building Web Applications 47
You can use this type of discovery document to exclude particular folders from
the dynamic discovery process. The folders excluded in the previous example
are those used for Microsoft FrontPage® Extensions and any Web references
used by the project, but you can manually list as many folders as you want.
The preceding dynamic discovery document will produce the following results
when queried by a client application:
<?xml version="1.0" encoding="utf-8"?>
<discovery xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.xmlsoap.org/disco/">
<contractRef ref="http://www.nwtraders.msft
/Shopping/User.asmx?WSDL"
docRef="http://www.nwtraders.msft/Shopping/User.asmx"
xmlns="http://schemas.xmlsoap.org/disco/scl/" />
<soap address="http://www.nwtraders.msft/Shopping/User.asmx"
xmlns:q1="http://tempuri.org/ binding="q1:Service1Soap"
xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>
You can view the description page by entering the Web Service URL in a
browser by using the following syntax:
http://webservername/virtualdirectory/webservice.asmx
You can also view the description page within Visual Studio .NET by right-
clicking the .asmx file in Solution Explorer, and then clicking View In
Browser.
Near the top of the HTML description page, there is also a “Service
Description” hyperlink to the WSDL document.
It is possible to read and interpret the WSDL document, but it is not necessary
to understand the document to use a Web Service.
54 Module 7: Building Web Applications
Syntax
You use the following syntax to invoke a Web Service:
http://webservername/vdir/webservicename.asmx/
MethodName?parameter=value
Example
The following example shows how to invoke a Web Service. This code calls the
AddUser method of the User.asmx Web Service in the Shopping virtual
directory on the nwtraders.msft Web server. It also passes in a parameter value
of the user name Joe.
http://www.nwtraders.msft/Shopping/User.asmx/
AddUser?strName=Joe
The Web Service will return XML output containing the results of the
execution as shown in the following example. The results show a String value
of 43-124-21 being returned as the new identity of the added user.
<?xml version="1.0" ?>
<string xmlns="http://tempuri.org/">43-124-21</string>
This approach uses the HTTP-GET protocol and would most commonly be
used for testing purposes; real application-to-application communication would
use the more powerful SOAP protocol.
Module 7: Building Web Applications 55
When you add a Web reference to your client project, Visual Basic .NET
creates a proxy class that hides the complexity of calling a Web Service. This
proxy allows you to use early binding when connecting to the service, as if the
components were accessible within a local assembly.
56 Module 7: Building Web Applications
Example
In the following example, the required Web Service has taken a Web reference,
and the Web reference has been renamed as the Services namespace. A
command button named btnSubmit and a TextBox named txtName have been
placed on a Windows Forms form with the following code for the
btnSubmit_Click event handler:
Private Sub btnSubmit_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSubmit.Click
'Services is the given namespace
Dim usr As New Services.User( )
MessageBox.Show(usr.AddUser(txtName.Text))
End Sub
When the preceding code is executed, a new user is created. The txtName text
box specifies the name of the new user, and the AddUser method creates a
message box that displays the new identity.
Module 7: Building Web Applications 57
In this animation, you saw how you can use Web services in your
Visual Basic .NET applications, how the Web Service Description Language
provides information about the Web service, and how Visual Basic .NET uses
SOAP to create proxies.
60 Module 7: Building Web Applications
Prerequisites
Before working on this lab, you must be familiar with creating Web Services in
Visual Basic .NET.
Scenario
In this lab, you will create a Web Service that allows retrieval and storage of
customer details. You will also create a Windows Forms application to test the
Web Service methods. Web Services are often used by other Web Services or
Web Form applications. A Windows Forms application will be used as the test
application in this lab to contrast using a class from a form with using a Web
Service from a form.
The Customer class from Lab 5.1, Creating the Customer Class, of Course
2373B, Programming with Microsoft Visual Basic .NET, is provided and will
be used as a basis for the Web Services application to replicate data retrieval
and storage. The test form from the same lab has been modified and supplied to
test these lab exercises.
Module 7: Building Web Applications 61
Exercise 1
Creating the CustomerService Web Service
In this exercise, you will create the CustomerService Web Service and define its
methods.
Exercise 2
Creating the LogOn Test Code
In this exercise, you will test the LogOn method of the Web Service from a
simple form.
strEmail txtEmail.Text
strPassword txtPassword.Text
intID intId
strFName strFName
strLName strLName
strAddress strAddress
strCompany strCompany
Module 7: Building Web Applications 65
4. Assign the following values to the text boxes following the call to the
LogOn method.
Text box Value
txtID CStr(intId)
txtFName strFName
txtLName strLName
txtAddress strAddress
txtCompany strCompany
E-mail [email protected]
Password password
4. Click the Logon button and confirm that the customer information is
displayed correctly in the text boxes.
5. Close the application.
66 Module 7: Building Web Applications
Exercise 3
Testing the GetDetails Procedure
In this exercise, you will test the GetDetails Web Service method from the test
form. Continue working with the project from the previous exercise. If you did
not complete the previous exercise, you can use the Ex03.sln project located in
the install folder\Labs\Lab072\Ex03\Starter folder.
intID CInt(txtID.Text)
strEmail strEmail
strPassword strPassword
strFName strFName
strLName strLName
strAddress strAddress
strCompany strCompany
4. Assign the following values to the text boxes following the call to the
GetDetails method.
Text box Value
txtEmail strEmail
txtPassword strPassword
txtFName strFName
txtLName strLName
txtAddress strAddress
txtCompany strCompany
Exercise 4
Testing the AddCustomer Procedure
In this exercise, you will test the AddCustomer Web Service method from the
test form. Continue working with the project from the previous exercise. If you
did not complete the previous exercise, you can use the Ex04.sln project located
in the install folder\Labs\Lab072\Ex04\Starter folder.
strEmail txtEmail.Text
strPassword txtPassword.Text
strFName txtFName.Text
strLName txtLName.Text
strAddress txtAddress.Text
strCompany txtCompany.Text
If Time Permits
Using a Web Service from a Web Application
In this optional exercise, you will use the Web Service from a Web application.
strEmail txtEmail.Text
strPassword txtPassword.Text
intID intID
strFName strFName
strLName strLName
strAddress strAddress
strCompany strCompany
E-mail [email protected]
Password karen
3. Click the Submit button to confirm that the error message is displayed.
4. Enter the following values in the appropriate text boxes.
Textbox Value
E-mail [email protected]
Password password
5. Click the Submit button, and confirm that the correct name is displayed on
the Welcome page.
6. Close the browser and Visual Studio .NET.
Module 7: Building Web Applications 71
Review
Topic Objective
To reinforce module
objectives by reviewing key
points. Introduction to ASP.NET
Lead-in Creating Web Form Applications
The review questions cover
some of the key concepts Building Web Services
taught in the module.
Using Web Services
3. Create a line of code that uses the Response object to retrieve a userCounter
session variable and display it to the user.
Response.Write("Value: " & Session("userCounter").ToString)
5. What attribute do you add to class methods when creating a Web Service?
WebMethod.
6. Visual Basic .NET allows early binding to a Web Service. True or false?
True. Setting a Web reference to a discovery document allows
Visual Basic .NET to create a proxy class that allows early binding in
the client application.