Slide 00

Saturday, September 06, 2008 12:11 AM

Instructor Notes (PPT Text)
This introduction module provides students with an overview of the course content materials and logistics for Course 2310C, Developing ASP.NET Web Applications by Using Microsoft Visual Studio 2008. Required materials To teach this course, you need the following materials: • Course Handbook • Course Companion CD • Trainer materials including: • Trainer Preparation Guide • Microsoft Office PowerPoint® files for this course • Microsoft Virtual PC/Server Classroom Setup Guide • Virtual machines for the course • Latest error logs for the course (if any) Important It is recommended that you use PowerPoint 2002 or a later version to display the slides for this course. If you use PowerPoint Viewer or an earlier version of PowerPoint, all the features of the slides might not be displayed correctly. Preparation tasks To prepare for this course, you must follow and complete the tasks outlined in the Trainer Preparation Guide. Presentation: 20 minutes

Module 00-Course Overview página 1

Slide 01
Saturday, September 06, 2008 12:11 AM

Instructor Notes (PPT Text)

Welcome students to the course and introduce yourself. Provide a brief overview of your background to establish credibility. Ask students to introduce themselves and provide their backgrounds, product experience, and expectations of the course. Record student expectations on a whiteboard or flip chart that you can reference during class.

Module 00-Course Overview página 2

Slide 02
Saturday, September 06, 2008 12:11 AM

Tell students that everything they will need for this course is provided at their desks. Have students write their names on both sides of the name cards if name cards are provided. Describe the contents of the Course Handbook and the Course Companion CD. Explain that the Course Handbook is meant to be used in conjunction with the Course Companion CD. Specifically, explain that: • The Course Handbook is meant as: • a succinct classroom learning guide • a quick on-the-job reference (particularly with the end-of-module takeaways section) • The Course Companion CD provides the full course content with: • more detailed support information for each topic • complete lab exercise information and procedures to use during lab time • well categorized reference materials for extended learning support Explain how you intend for students to use the Course Handbook and the Course Companion CD during the class. Demonstrate how to open the Course Companion CD and how to navigate the companion content structure. Tell students where they can send comments and feedback on this course. Tell students that they will have an opportunity to provide course evaluation at the end of the course.

Instructor Notes (PPT Text)

Module 00-Course Overview página 3

Slide 03
Saturday, September 06, 2008 12:11 AM

Instructor Notes (PPT Text)

Explain the class hours, extended building hours for labs, parking, restroom location, meals, phones, message posting, and where smoking is or is not allowed. Let students know if your facility has Internet access that is available for them to use during class breaks. Also, make sure that the students are aware of the recycling program if one is available.

Module 00-Course Overview página 4

Slide 04
Saturday, September 06, 2008 12:11 AM

Instructor Notes (PPT Text)

Explain that course 2310 is not a direct prerequisite to course 6463 but that some students may benefit from taking both courses. Explain the Microsoft Learning program and present the list of additional recommended courses. Refer students to the Microsoft Learning Web page at http://www.microsoft.com/learning/ for information about curriculum paths

Module 00-Course Overview página 5

Slide 05
Saturday, September 06, 2008 12:11 AM

Instructor Notes (PPT Text)

This course does not map to any specific certification exam. Explain that Microsoft® Learning offers a variety of certification credentials for developers and IT professionals. If the students require more information, describe the key developer certifications such as Microsoft Certified Technology Specialist (MCTS) and Microsoft Certified Professional Developer (MCPD). Direct the students to the link provided on the slide. Inform students about the Microsoft Certified Professional (MCP) program, any certification exams that are related to this course, and the various certification options.

Module 00-Course Overview página 6

Describe the course objectives. This is an opportunity for you to identify students who may not have the appropriate background or experience to attend this course. September 06. Module 00-Course Overview página 7 . 2008 12:11 AM Instructor Notes (PPT Text) Describe the audience and the prerequisites for this course.Slide 06 Saturday.

Module 00-Course Overview página 8 . 2008 12:11 AM Instructor Notes (PPT Text) Briefly describe each module and what students will learn. Explain how this course will meet students' expectations by relating the information that is covered in individual modules to their expectations. September 06.Slide 07 Saturday.

Slide 08 Saturday. 2008 12:12 AM Instructor Notes (PPT Text) Module 00-Course Overview página 9 . September 06.

Describe the virtual machine lab environment. Module 00-Course Overview página 10 . Briefly describe the names and roles of the virtual machines that students will use for the lab exercises. Explain that all student computers have the same configurations.Slide 09 Saturday. September 06. Explain that the course files (lab files required for performing the labs) are located in the folder E: \Labfiles on the student computers. 2008 12:12 AM Instructor Notes (PPT Text) Tell students that they will use Microsoft Virtual Server to perform the labs.

September 06. 2008 12:12 AM Instructor Notes (PPT Text) If the course does not use virtual machines.Slide 10 Saturday. Module 00-Course Overview página 11 . this topic is not necessary.

Slide 11 Saturday. September 06. 2008 12:12 AM Instructor Notes (PPT Text) Module 00-Course Overview página 12 .

which is the development tool that you will use to develop Web applications by using the .NET Framework Saturday.NET and the .NET Framework solves these problems.NET Framework página 13 . 2008 12:12 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 1 Introduction to the . It describes some of the problems that developers confront while they develop Web applications and explains how the .NET Framework This lesson introduces Microsoft .NET Framework.Introduction to the . This lesson also introduces Microsoft Visual Studio ® 2008.NET Framework. Module 01-Overview of the Microsoft . September 06.

NET Framework components in depth here because there is a slide for that later in the course.NET? Key Points Microsoft . Microsoft .NET-Framework solutions on servers such as Microsoft Windows Server 2003™ and Microsoft SQL Server™. 2008 12:12 AM Instructor Notes (PPT Text) The key point about the Microsoft® .NET can include the following technologies: The .NET is a development model that you can use to create platform-independent and device-independent software.NET.NET can include the following technologies: The .NET enables developers to deliver a comprehensive user experience across a family of devices such as mobile devices.NET Framework página 14 . which will be covered in more depth later. September 06.NET technologies does your workplace currently use? CD Content Microsoft . The . Clients.NET Framework is the infrastructure of Microsoft . Components of Microsoft . Module 01-Overview of the Microsoft .NET Framework provides a programming model that enables developers to build Windows and Web applications and XML Web services.NET Framework Servers Clients Visual Studio 2008 Question: Which Microsoft . Student Book Content What Is Microsoft . The .NET Saturday. Briefly name some of the features of the common language runtime (CLR). The goal of Microsoft . and manage . Servers. Web browsers.NET Microsoft .NET Framework is that it is a platform-independent and deviceindependent system that is designed to work over the Internet.NET is to simplify the development of Web and other applications. Do not cover the . Microsoft .NET provides an infrastructure to integrate. You can also use the .NET is built from the ground up on open architecture and you can use it to build and run the next generation of Microsoft Windows ® and Web applications. and personal computers.NET Framework to make data available over the Internet. run.What Is Microsoft . operate. Microsoft .NET Framework.

The .0 and 3.5 of the . Windows Vista™. Version.NET Framework version 3. Student Book Content The . meaning there is one Forms model for all languages.NETbased applications.5 of the .NET Framework must run on an operating system.5 are Microsoft Windows Server ® 2003.NET Framework provides a choice of development languages.NET Framework builds incrementally on features from the previous two versions. which provides common services such as garbage collection and security. Mention that the user interface (UI) and ASP.NET Framework. there are many different items to consider including current network environment.NET Framework The . you can develop a Microsoft .NET compiler then transforms your source code and creates a managed module. Discussion Question: Do not spend too much time on the discussion point. Module 01-Overview of the Microsoft . user skill level. The . September 06. There are several "correct" answers. Which technologies may be suitable for this new application? CD Content The . This can easily become more of a question along the lines of what is "appropriate" rather than suitable. The . The .NET Framework provides the necessary compile-time and run-time foundation to build and run Microsoft . The supported operating systems for the . The CLR environment is a managed environment. however.0 and 2.0.NET Framework class library implements the .NET-based applications: Operating System.NET Framework. and Windows XP. The . and development time. The CLR simplifies application development.NET Framework página 15 . By using the CLR. 2008 12:12 AM Instructor Notes (PPT Text) Mention that this course covers version 3. Briefly cover each key component.NET Framework Components Saturday. supports multiple languages. provides a robust and secure execution environment.NET Framework consists of different components that help you to build and run Microsoft .NET are below the languages.0. namely 2. Distinguish between this version and version 3.The . 3. Common Language Runtime.NET Framework Components Key Points The CLR environment is a managed environment. which the CLR on the client computer can execute.NET solution by using the programming language of your choice. and simplifies application deployment and management. Question: You have been asked to build a new distributed and service-oriented Web application in a Microsoft Windows ® environment.

5 technologies include: Language Integrated Query (LINQ). Student Book Content Windows Forms. The .NET Framework 3. "Accomplishing Complex Data Access Tasks. which simplifies the security of working online by using personal identity information in the form of virtual business cards. which provides a programming model and tools to build workflow-enabled applications that model business processes. Windows CardSpace.0 Technologies The . .5 also provides new features in several technology areas. Windows Workflow Foundation (WF).5.5 Technologies The latest version of the . These features are contained in new assemblies to avoid breaking existing applications that are written for previous versions of the . .NET Framework 3.NET Framework 3. Note:For more information about LINQ.0.0 builds on the .0 is included as part of the Windows Vista operating system and is available for Windows XP and Windows Server 2003. builds incrementally on the new features added in the . September 06. which enables you to create more efficient and interactive Web applications.NET Framework version 3. Windows Presentation Foundation (WPF)." ASP.NET Framework 3.NET Framework 3.0 technologies are: Windows Communication Foundation (WCF). and media. see Module 9.NET Framework Saturday.NET Framework in developing Web applications. which provides the functionality to develop executable applications that run on client computers.NET Framework 3. which enables you to write code to access and manipulate data by using any LINQ-enabled language. documents. The .NET Framework version 2.0 and provides new technologies to help you develop the next generation of distributed applications. which provides a unified programming model for service-oriented applications.NET Framework página 16 .NET Framework 3.NET Framework. which provides classes for smart-client applications that combine user interface.NET AJAX. 2008 12:13 AM Instructor Notes (PPT Text) Discuss the benefits of the . The . Module 01-Overview of the Microsoft .NET Framework. the . The .Benefits of the .NET Framework 3.

The Tool for .0. along with easily accessible help and documentation.NET AJAX. Windows Workflow Foundation (WF). However.5). Visual Studio 2008 is designed to support the developer all the way through the development process. 2008 12:13 AM Instructor Notes (PPT Text) Inform the students that if they have the .NET Development Saturday. Windows-based. including the following: Multi-targeting support to enable developers to select which version of the . including Web.NET Framework they want their application to target (2. by using Microsoft Notepad only). Student Book Content Visual Studio 2008: The Tool for . and ASP.NET Framework página 17 . Tools for building many different types of application. Module 01-Overview of the Microsoft . September 06. Complete error-handling and debugging.NET Development Key Points Visual Studio 2008 is a complete development environment that provides many features. Windows Presentation Foundation (WPF). 3. they can build programs without Microsoft Visual Studio® 2008 (for instance.NET Framework installed on their computers.Visual Studio 2008 . or 3. Visual Studio 2008 is a great development environment that makes developing Web applications a rich experience for developers. Windows Communication Foundation (WCF).0.

NET Web Forms.Overview of ASP. 2008 12:13 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 2 Overview of ASP. September 06.NET and ASP. ASP. ASP.NET Web applications. Module 01-Overview of the Microsoft .NET Framework página 18 .NET also includes the technology to build XML Web services. provide an easy way to build dynamic Web sites.NET ASP. which provide the building blocks for the construction of distributed Web-based applications.NET Saturday.NET is a programming framework for building Web applications.NET Web application. which are part of an ASP. This lesson describes the key features of ASP.

A Web Form is a dynamic page that can access server resources.NET Web application. A Web Form is the Web page that users view in a browser. Similar to ASP. personalized Web sites. However.NET Web applications in any . Module 01-Overview of the Microsoft .NET. and 2. 2008 12:13 AM Instructor Notes (PPT Text) Mention that ASP. you can develop ASP. Student Book Content What Is ASP. however.NET Web Form does not rely on client-side scripting. September 06.NET is a set of Web application development technologies.NET is the successor to ASP and that there have been several versions of ASP. Explain that each successive version of ASP. and XML Web services. ASP. A deployed ASP. emphasize that students must use Internet Information Services (IIS) to host the deployed Web application. to generate additional Web Forms. developers have used ASP technology to build dynamic Web pages. or to take advantage of built-in security on the server. dynamic. a traditional HTML Web page can run script on the client to perform basic tasks.NET application runs as a process in Internet Information Services (IIS). such as 1. An ASP. For example.NET is a set of Web application development technologies that enables programmers to build dynamic Web sites. In addition.0.NET-based language.NET offers many improvements over ASP.1. What Is ASP. it is not dependent on the client's browser type or operating system. The fundamental component of ASP. Mention the development server that is provided as part of the Visual Studio 2008 suite of tools. In addition.NET Framework página 19 .What Is ASP. Because ASP.NET Web application consists of one or more Web Forms.NET? Microsoft ASP.NET Framework. an ASP.NET Web Form can also run server-side code to access a database. You can use Visual Studio 2008 to build and execute an ASP.NET is part of the .NET? Key Points Microsoft ASP. because an ASP. CD Content For many years. 1.NET runs on a Web server and provides a way for you to develop content-rich.0. ASP. ASP. Web applications.NET is the Web Form. This independence enables you to develop a single Web Form that you can view on practically any device that has Internet access and a Web browser.NET applications consist of one or more Web Forms and developers can use Visual Studio 2008 as an environment to build and test these applications.NET aims to increase the productivity of developers but requires them to write less code. This results in a simplified development process because you can test the application without creating an external hosting environment.NET Saturday.

Discuss the different components at a high level. How many different pages and other components may be required to build that Web site? CD Content An ASP. including the following: Web Forms (. Configuration files.NET Web application include: Web Forms.NET page. Question: Think of a typical production Web site with which you are familiar such as your company's intranet site.NET Web Applications Saturday.NET Web application contains different components. Module 01-Overview of the Microsoft . which provide the UI for the Web application.asax files contain code for responding to application-level events that are raised by ASP. which resides in the . Components The components of an ASP. Student Book Content ASP.aspx pages. which contains both the page markup and the .aspx pages).ASP.NET Framework página 20 .NET Web application contains several different components. you must understand how to implement and use all of these components.aspx page or in a code-behind page. Web Forms provide the UI for the Web application.NET. You can also create a single-file ASP. September 06. which are XML files that define the settings for the Web application and the Web server. Global. Configuration files.NET Web Applications Key Points An ASP.asax file.config file. Code.NET Framework code in the same file.config configuration files. Configuration files are XML files that define the settings for the Web application and the Web server. each Web server has only one machine. or . 2008 12:13 AM Instructor Notes (PPT Text) This topic focuses on what constitutes an ASP.NET Web application. Code-behind pages. When you create a Web application. Every Web application has one or more web. Global. Code-behind pages are associated with Web Forms and contain the server-side code for the Web Form. In addition.

Which form of compilation would be the best choice for this scenario: dynamic compilation or precompilation? CD Content ASP. The compiled resources are then cached.Multimedia . Explain the steps as the multimedia runs: • First. the following set of events take place: 1.NET Dynamic Compilation Execution Model Key Points ASP. ASP. 3. which ensures that subsequent requests are performed efficiently. The client browser issues a GET HTTP request to the server.NET works to send information to a requesting client. Dynamic compilation ensures that pages are compiled on first request.NET invokes the compiler. Instructor Notes (PPT Text) Student Book Content Multimedia: ASP.NET Web pages and code files use dynamic compilation by default when a user requests a resource for the first time.NET Web pages and code files use dynamic compilation by default. regardless of whether the page is in the cache. Precompilation provides improved response time on first request and a means to identify errors. you will see how dynamic compilation in ASP. • Second. This requires constant updates to multiple Web pages. 4. the request shows that the page is compiled and then processed.NET parser interprets the source code. 2008 12:13 AM There is no sound in this animation. In this animation.NET Dynamic Compilation Execution Model Saturday. Module 01-Overview of the Microsoft .ASP.NET Framework página 21 . First Request When the client requests a Web page for the first time. Mention that. The runtime loads and executes the Microsoft intermediate language (MSIL) code. If the code was not already compiled in a dynamic-link library (DLL). parsing will occur if the content changes and recompiling will occur for any code change. Question: You are developing and testing a new Web site. 2. The ASP. the request shows that the page is directly processed. September 06.

NET Framework Resources Saturday.NET Framework. The Start menu of your Windows operating system. You can access the .NET Framework documentation. Microsoft MSDN® Offers help for developers who write applications by using Microsoft products and technologies. Visual Studio 2008. ASP.NET Framework documentation in two places. along with answers to specific questions: The . CD Content The following list of resources provides you with a starting point to find more information about the .NET development community.NET Framework Resources Key Points There are many resources available to help you find further information and troubleshoot problems when you develop by using the .NET Framework página 22 .Microsoft .NET. Channel 9 Channel 9 is a Microsoft discussion forum used to promote conversations among Microsoft's customers.NET 2. CodePlex CodePlex is Microsoft's open source project hosting web site. Module 01-Overview of the Microsoft . 2008 12:13 AM Instructor Notes (PPT Text) The goal in this lesson is to give students options for finding information about Microsoft . September 06.NET The ASP.0 site is a portal site for the ASP. Student Book Content Microsoft .NET Framework.

September 06. You will also have the opportunity to explore a complete version of the lab application and understand some of its functionality.Overview of the Lab Application Saturday.NET Framework página 23 . 2008 12:13 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 3 Overview of the Lab Application This lesson introduces the lab application that you will build throughout the remainder of this course. Module 01-Overview of the Microsoft .

Page or file name Description benefitsMaster. This fictitious Web site provides information to employees about their benefit options. you can develop lab solutions by using either Microsoft Visual C# ® or Visual Basic.NET Web application that simulates an internal Web site for the fictitious company. CD Content In the labs in this course. This fictitious Web site provides information to employees about their benefit options.aspx doctors.xml header. Throughout this course. 11 Web Forms that display the employee benefits information. Note:Throughout this course. which consist of a Web site and an XML Web service. September 06. you can develop lab solutions by using either Visual Basic or Visual C#. you will build a complete ASP.ascx User control that is the header of each page Module 01-Overview of the Microsoft .xml lgcap. Calls the BenefitsList component and lists the benefits options in a CheckBoxList control Calls the XML Web service to get a listing of dentists Lists the primary care physicians from the Doctors SQL Server database XML files with the prospectus information . you will build a complete ASP. The following table lists the Visual Basic and Visual C# components of the Benefits Web application.mast Master page er Default. Two SQL Server databases. students can choose to develop lab solutions by using either Microsoft Visual Basic® or Microsoft Visual C#®.xml midcap.aspx growth.NET Framework página 24 Home page.Lab Application Setup Saturday.NET Web application that simulates an internal Web site for the fictitious company. Solutions are provided for both languages.aspx dental. Coho Winery. Student Book Content Lab Application Setup Key Points In the labs in this course. 2008 12:13 AM Instructor Notes (PPT Text) This list gives a sense of the scale of the Web application project that the students will create by the end of the course.xml smcap. Details The Benefits Web application includes the following components: Two projects. Throughout this course. Coho Winery.

aspx mutual_funds.aspx Input form for life insurance data.xml file in an HTML format Displays the identity and the authentication method that is used to authenticate the current user.aspx retirement.config Input form for medical data. Used on the medical.xsl Style sheet file for displaying the prospectus Benefits component Contains a Visual Basic or Visual C# component named Benefits that returns a list of benefit options DentalService Web service project Doctors.ascx nestedData.aspx web.xml namedate.ascx User control that is the header of each page life.aspx securitytest.NET Framework página 25 .asmx.header.dbml Contains an XML Web service named DentalService. to test the security system Configuration file prospectus_style. This XML Web service reads information from the Dentists SQL Server database and returns the information as a dataset LINQ to SQL Classes file Module 01-Overview of the Microsoft .aspx register. Uses validation controls Logon page for the Web site medical.aspx prospectus.aspx Login. The page used for selecting primary care physician from the doctors.aspx page XML file containing the list of mutual funds User control that is used to gather name and birth date information.aspx page Enables you to create a nested XML file from the several tables that the Doctors database includes Displays a retirement fund prospectus from an XML file by using a style sheet file Adds new users to the Coho Winery database Displays XML data from the mutual_funds.

The lab application is composed of the following: Several Web Forms A component Two user controls An XML Web service. Save and build the web site. 11. click the medical link. View one or more of the prospectus's.NET Framework 3. use the link to select a doctor and then save the changes. In the Default. In the Default. 15. 8.aspx page. A Command Prompt window opens. 22. 23. Click Home.The Lab Solution Saturday.dll file from the www. In Visual Studio 2008 open the Benefits Web site from the E: \Democode\Lab Solution folder. 16. and Dental benefits. 2008 12:13 AM Instructor Notes (PPT Text) • • • • The lab application is an ASP.aspx page. Use Pa$$word as the password. Note: This demonstration requires the AjaxControlToolkit. At the command prompt. Click Get All Dentists. Fill in a name. The benefits proposed are Life Insurance.dll file that targets the official release of . Retirement. type the following command. date of birth. click Dental. 21. There are also two main databases: one that contains the list of doctors that are used for the medical benefit and another that contains the list of dentists and is used by the XML Web services. 3.5 and Visual Studio 2008. On the medical page. 17.aspx file in the browser. aspnet_regsql -S LONDON\SQLExpress -E -ssadd You must perform this step because the ASPState database does not exist in the virtual machine for this lab. To run the demonstration: 1. 5.NET Framework página 26 . 2. Medical. delete and then recreate the DentalWebRe f Web reference that points to the DentalService Web service. Click Create User 12. Module 01-Overview of the Microsoft . Click Register New User. 4. 13.Demonstration . 7. 9. In the Default. In the Benefits Web site.codeplex. and then click Visual Studio 2008 Command Prompt. View the Default. 10. Close Visual Studio 2008. 19.NET Web application named Coho Winery. Close Internet Explorer. Click Save. click the life insurance link. Close the command prompt window. and coverage and click one or both of the check boxes. 20. September 06. Coho Winery is a fictitious company that offers several benefits to its employees.com Web site and copy it to the E:\Democode\Lab Solution\Benefits\Bin folder in the virtual machine.aspx page. expand the Visual Studio Tools folder. expand the Microsoft Visual Studio 2008 folder. 14. Fill in the details of a user. Download the latest version of the AjaxControlToolkit. point to All Programs. and then press ENTER. 6. Click Start. Click Retirement account. 18. Add the DentalService Web service to the solution.

Student Book Content Module 01-Overview of the Microsoft .NET Framework página 27 .

This lesson introduces the Visual Studio 2008 IDE.Overview of Visual Studio 2008 Saturday. September 06.NET-Based Languages página 28 . 2008 12:15 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 1 Overview of Visual Studio 2008 The Visual Studio 2008 integrated development environment (IDE) is the common user interface (UI) and set of tools that you can use for all of the different project types and programming languages that Visual Studio 2008 supports. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .

and Workflow designer and project support. 2008 12:15 AM Instructor Notes (PPT Text) The key point regarding Microsoft® Visual Studio® 2008 is that it provides the tools to make students better. mention multitargeting support and the inclusion of Windows Presentation Foundation (WPF). regardless of the programming language or application type. Student Book Content Why Visual Studio 2008? Key Points Visual Studio 2008 simplifies the development of powerful and reliable enterprise Web solutions and increases developer efficiency by providing a familiar. Mention several of the new features that Visual Studio 2008 provides. Supports multiple languages and the development of multiple project types. faster. Supports debugging from your initial code through to the application release and customization at the window and application level. Visual Studio 2008: Provides an IDE with a consistent look and feel.Why Visual Studio 2008 Saturday.NET-Based Languages página 29 . and more accurate programmers. Windows Communication Foundation (WCF). Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . September 06. shared development environment. For example.

the creation of test projects may be available only with specific editions of Visual Studio such as Team Foundation Suite Edition. Note: Open Visual Studio 2008 before you display this slide and show the New Project dialog box. These templates contain all of the required files and ensures that the IDE has the correct configuration for the selected project. test project availability can be verified only after the product is officially released.Available Project Templates Saturday. When you create a project in Visual Studio 2008. Also. Ensure that students are aware of this. This is a critical concept for the organization of Web applications.NET-Based Languages página 30 . you also create a larger container called a solution that can also contain multiple projects. Student Book Content Available Project Templates Key Points Visual Studio 2008 provides templates that support the creation of a number of common project types. 2008 12:15 AM Instructor Notes (PPT Text) Emphasize that a solution contains multiple related projects and these projects contain multiple Web pages called Web Forms. Do not spend more than the allotted time on this information. September 06. Question: What project templates does Visual Studio 2008 provide? Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Visual Studio 2008 includes multiple project templates in different languages.

demonstrate the environment settings that are available when you open Visual Studio for the first time. You can also briefly discuss other useful options here. closing. Student Book Content Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Demonstrate features such as autohide.NET-Based Languages página 31 . Explain the environment settings that are available when you open Visual Studio for the first time. a quick look is all that is required. and opening of windows. docking. floating. especially if the Visual Studio 2008 integrated development environment (IDE) is familiar to your students or they have used previous versions of Visual Studio. Note: Do not go into too much detail demonstrating the Object Browser.Integrated Development Environment Saturday. September 06. for example. You can come back to this later in this module to examine the hierarchy of namespaces if required. discuss the default HTML designer view and full screen mode (developers that use multiple monitors can take advantage of these options). If time permits. 2008 12:15 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on this information. Alternative delivery: You can open Visual Studio 2008 and show the screens as you talk about what each screen does. also point out the window layout options and tabbed documents versus multiple documents. If so.

and managed Web services. Visual Studio 2008 provides a template for a test project. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .Creating an ASP. and blank solutions.NET Web Application Project Saturday. 2008 12:15 AM Instructor Notes (PPT Text) Lesson overview Student Book Content The following table lists the additional project templates that are available in Visual Studio 2008. extensibility projects. managed applications. September 06. Template Group Visual C++ Projects Description Visual Studio 2008 includes templates for ATL projects. managed class libraries. Other Projects Test Projects Visual Studio 2008 includes templates for setup and deployment projects.NET-Based Languages página 32 . database projects.

as shown in the following list: Create a new project: Modules 2 and 4 Create the interface and write code: Modules 2. Test and debug. and 4. you must perform the following basic steps: 1. 4. Student Book Content The Development Process Key Points Visual Studio 2008 contains everything you require to build your own ASP. 6. 3. September 06. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET Web application from start to finish. 2008 12:15 AM Instructor Notes (PPT Text) • • • • • The goal of this topic is to show how much of the development process is supported by Visual Studio 2008. Create a design specification.NET Web application by using Visual Studio 2008. 5. 2. Deploy. This is an additional opportunity to highlight the content that will be covered in this course.NET-Based Languages página 33 . Build. 3. class diagrams). To create an ASP.The Development Process Saturday. Build: All modules Test and Debug: Modules 2 and 6 Deploy: Module 13 (XML Web services) and Module 16 (Web applications) Note that some design features are available in Visual Studio 2008 (for example. Create a new project. Create the interface and write code.

com/fwlink/?LinkId=110685 Alternative delivery: You can open Visual Studio 2008 and show the screens as you talk about what each screen does. Student Book Content Web Application Types and File Structure Key Points In Visual Studio 2008.NET-Based Languages página 34 .NET Web Application project template. 2008 12:15 AM Instructor Notes (PPT Text) The goal of this topic is to explain the two project templates for the creation of Web applications and to show the students where the files are located. ASP. Provides a Web project model with more features and additional flexibility in the management of Web applications. Discussion will enable the students to gain a deeper understanding of how to choose a particular template to start a project. Remind the students that this can be a good resource for later in the course when they are trying to identify where the files are located. For more information about the differences between the two templates. show the use of both templates. September 06. show the hidden folders in Solution Explorer. and open Microsoft Windows® Explorer to show the files that are created. what files does Visual Studio provide? Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . The choice of project template depends on your requirements and your preferred development workflow.Web Application Types and File Structure Saturday. you can create a Web application by using two different templates: ASP.NET Web Site project template. If time permits. Provides a Web project model that is similar to the Visual Studio 2003 Web project model. Question: When you create a Web application. Note: The choice of project template can be a good point to generate some discussion on your choice of project. see http://go.microsoft.

a Crystal Report file uses the .aspx. ASP.cs). Other files. Alternative delivery: You can open Solution Explorer and show the files with extensions. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . To avoid later confusion.Web Application Files Saturday.NET Web services (. 2008 12:15 AM Instructor Notes (PPT Text) This slide lists only the most important file types. Any files that are not based on a programming language will have their own extensions. Student Book Content Web Application Files Key Points In Visual Studio 2008. and a Web Form.asmx). emphasize the difference between a solution.vb or .aspx (Web Form) and . September 06.NET Web Forms (. Visual Studio 2008 supports a number of application file types and extensions such as ASP.aspx).cs (code-behind page).rpt extension and a text file uses .aspx. a project. you can create a number of files that support the development of your Web application: Web application files. and classes and code-behind pages (.NET-Based Languages página 35 .txt. For example.vb or . The two most important file extensions for the students are .

Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . The cursor jumps to the correct spot in the code. 5. Add a new project • Add a new ASP. Add a new ASP. Write code for the Button control 1. 4.Creating a Web Application Project Saturday.aspx file in Design view.Text = "Hello World!" 5. This demonstration also shows how to add controls to the application. Create a new ASP. 4. Write the following code. This error is there to show the students what happens when the build fails. The TODO task disappears automatically from the Task List. [Visual C#] messageLabel.Text = "Hello World!".Txt = "Hello World!". Remove the TODO from the TODO: Write Hello World comment. click Comments.Txt = "Hello World!" Note: This is a syntax error because the code sets the Txt property instead of the Text property.UI. and then add the following comment to the event procedure. 2. 3.NET Web Service project named MyFirstWebService to the solution. [Visual C#] messageLabel.Demonstration . Double-click the error message in the Task List. 2008 12:15 AM Instructor Notes (PPT Text) • • • • • Explain to the students that the goal of this demonstration is to show the files and default code that are created when they start a new project. The correct file is opened and the cursor is placed at the correct spot in the code. [Visual Basic] messageLabel. Correct the syntax error.NET-Based Languages página 36 . Select the label and in the Properties window. Open the Default. In the Task List window. View the Web Form in a browser and ensure it displays the message Hello World when you click the Button control. Double-click the Button control to open the code-behind page for the Web Form. 6.NET Web Application project. and then double-click the TODO: Write Hello World task. September 06.We bControls. Verify that the Web application is the startup project.NET Web Form 1.NET Web Form • Add a new Web Form named login.aspx to the Web application project. 2. in the Categories list. 2. Populate the ASP.Web. Rebuild the solution and verify that it succeeds. [Visual Basic] messageLabel. 3. Build and debug the solution 1. Add a Button control and a Label control. [Visual C#] //TODO: Write Hello World [Visual Basic] 'TODO: Write Hello World A new task is automatically added to the Task List because of the TODO token. 3. change the ID property to messageLabel.Label. Build the solution and verify that an error message is added to the Task List because Txt is not a member of System.

Student Book Content Demonstration: Creating a Web Application Project Question: How can you can build and browse a Web Form in one step? CD Content In this demonstration. the instructor will show you how to create a Web application and implement some simple functionality. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 37 .

The . It also introduces namespaces. September 06.NET Framework. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .Overview of the Microsoft .NET Framework supports many programming languages.NET-Based Languages página 38 .NET Framework-based languages. This lesson describes the programming languages that are supported by the . 2008 12:15 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Overview of the Microsoft . it is designed to support an unlimited number of development languages. which are a fundamental feature of the .NET Framework and the .NET-Based Languages The .NET Framework requirements.NET Framework class library is an object-oriented library that is composed of namespaces which are reusable types that reduce development time. assuming that those languages conform to .NET-Based Languages Saturday.

September 06.NET applications and provides benefits such as reusable code modules. The design of the .NET Framework enables developers to use their preferred language when they develop . The design of the .NET applications. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . CD Content The . the . Currently.NET Framework supports a theoretically infinite number of development languages.NET Framework supports a theoretically infinite number of development languages. 2008 12:15 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Multiple Language Support Key Points The .NET Framework supports many languages.Multiple Language Support Saturday.NET Framework enables developers to use their preferred language when they develop . The following table lists some of these languages.NET-Based Languages página 39 .

for example. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Thus. it provides code security and solves DLL versioning problems.NET Framework.NET-Based Languages página 40 . Briefly explain the concept of Microsoft intermediate language (MSIL).NET Framework languages are compiled to MSIL and then to native code. The CLR also provides several other services. The CLR ensures that a . CD Content The common language runtime (CLR) is the runtime engine of the . the CLR allows multiple versions of a DLL to exist and run at the same time. Do not go into detail because this concept is covered in a later slide. Student Book Content The Common Language Runtime Key Points The common language runtime (CLR) is the runtime engine of the .The Common Language Runtime Saturday. September 06.NET Framework. The CLR manages application threading and garbage collection. 2008 12:15 AM Instructor Notes (PPT Text) List some of the supported languages. Explain that all . The CLR ensures that the correct version of the dynamic-link library (DLL) is available for the application.NET application is secure and will run properly.

After the application is compiled. the CLR executes the application on the Web server and then generates the HTML and script that is returned to the client. 2008 12:15 AM Instructor Notes (PPT Text) • • • • • • • • • • Explain the role and importance of the CLR.Runtime Compilation and Execution Saturday.NET-compatible language provides its own compiler to compile code to Microsoft intermediate language (MSIL). the CLR compiles the MSIL to native code by using a just-in-time (JIT) compiler and then runs the application. September 06. The available components are as follows: . After the code is compiled to MSIL.NET Framework class library support Thread support Type checker Exception manager Debug engine Garbage collector Class loader MSIL to Native compilers Code manager COM marshaler Student Book Content Runtime Compilation and Execution Key Points Each . Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 41 . After the application is JIT-compiled. it is cached so that it does not have to be recompiled for each request. Talk briefly about several of the different components.

CD Content The . September 06. Each namespace contains types that you can use in your application. and interfaces) that reduces development time and increases cross-language support.What Are Namespaces Saturday. Also explain JIT compilation and application execution. enumerations. delegates. the whole process begins again.NET-compatible development languages. structures. The library is a collection of reusable types (classes. Point out the difference for a precompiled Web application.NET-Based Languages página 42 .NET Framework class library is an object-oriented library that is composed of namespaces. 2008 12:15 AM Instructor Notes (PPT Text) Explain how a Web page is complied to MSIL. Student Book Content What Are Namespaces? Key Points Namespaces provide a logical grouping of classes that can be used by all . Mention that if any code file is changed. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .

CSC for Visual C# and VBC for Visual Basic. for example.NET Framework-based development language because ASP. CD Content The CLR is used for JIT compilation from MSIL to native code and provides an environment to run that code. The choice of development language for your Web application mainly depends on your previous development experience. September 06. Open the Object Browser to show that the namespaces are hierarchical.NET-Based Languages Key Points The choice of development language for your Web application mainly depends on your previous development experience. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .Comparison of the Microsoft .NET-Based Languages página 43 .NET code runs only on the server. Student Book Content Comparison of the Microsoft . Specific language compilers are used to compile to MSIL code.NET-Based Languages Saturday. 2008 12:15 AM Instructor Notes (PPT Text) Check if the students are familiar with the concept of namespaces. Browser compatibility is not a consideration when you choose a .

2008 12:15 AM Instructor Notes (PPT Text) Explain why it is important to know both the Microsoft Visual C#® and Microsoft Visual Basic® languages. when Visual Basic developers may have to read Visual C# source code (similarly for Visual C# developers).NET-Based Languages página 44 . you can use existing classes and components. for example. Highlight the fact that there is a possibility that developers may have to work on a solution that contains projects in both languages. You can use Visual Studio 2008 to create a component and use it in other applications. September 06. Student Book Content Lesson 4 Creating a Component by Using Visual Studio 2008 When you use an object-oriented language to develop an application. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . This lesson introduces classes and components. It explains how to create a component by using Visual Studio 2008 and how to use that component in other applications.Creating a Component by Using Visual Studio 2008 Saturday. You can emphasize that there can be situations.

September 06. For example. CD Content When you use an object-oriented language (such Visual C# or Visual Basic) to develop an application.NET-Based Languages página 45 . you can use existing classes and components: Classes are groups of code statements that provide functionality in an application. Because the component is its own file. you can reuse it in different parts of an application.NET Framework class library consists of many classes. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Components are classes that are compiled into a DLL file. you can use existing classes and components. the .What Are Classes and Components Saturday. 2008 12:15 AM Instructor Notes (PPT Text) Lesson overview Student Book Content What Are Classes and Components? Key Points When you use an object-oriented language (such Visual C# or Visual Basic) to develop an application.

data. Abstraction is a form of organization in which methods.NET-Based Languages página 46 . CD Content In object-oriented languages. A fundamental component of abstraction is the creation and use of classes. 2008 12:15 AM Instructor Notes (PPT Text) • • • • • Key terminology: Class Property Method Object Component Ensure that the students can confidently explain the difference between each of these concepts. Student Book Content Creating a Class Key Points When you create a class in a project. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . and functions that serve a common purpose are grouped together. you create a component that you can reuse. the class file is compiled into the application DLL and cannot be reused by other applications.Creating a Class Saturday. the concept of abstraction is important. If you create a class library. September 06.

you must reference the compiled assembly of the component (DLL).NET Web Form Key Points Classes that you create in a component are available to other programs. to access the methods in the class. September 06. you instantiate the class object by referencing its namespace and class name. it can be another project in your solution or a COM DLL. Also explain the default code that is generated. to access the methods in the class.NET-Based Languages página 47 . First.Accessing Components in an ASP. Then. CD Content Classes that you create in a component are available to other programs. you instantiate the class object by referencing its namespace and class name. The component does not necessarily have to be a . Then. Student Book Content Accessing Components in an ASP.NET Framework component. All of the public methods in the class are available for use. 2008 12:15 AM Instructor Notes (PPT Text) Briefly explain how to creating a class. you must reference the component (DLL). Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . First.NET Web Form Saturday.

Explain the code required to instantiate and use the object. September 06. in Visual Basic.Demonstration .dll file stored? CD Content In this demonstration. the root namespace is in the project properties. Identify that CompanyA is the root namespace here. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 48 . Student Book Content Demonstration: Creating a Class in Visual Studio 2008 Question: When you compile a class.Creating a Class in Visual Studio 2008 Saturday. the instructor will show you how to create a component and call it from a Web application. the root namespace is in code. Note: Explain the use of the namespace keyword. In Visual C#. where is the . 2008 12:15 AM Instructor Notes (PPT Text) Ensure that the students are familiar with the concept of referencing a DLL.

2008 12:15 AM Instructor Notes (PPT Text) • • • • Explain to the students that the goal of this demonstration is to show how to create a class library and call a class from an ASP. Create a method that returns a string 1. or other code that you want to reference in your application. Contains source code for utility classes and business objects (for example. Create a class in the App_Code folder 1. 2. Create a new Class Library project 1.SayHello(). other code anywhere in a Web application can automatically reference it. Class1. Contains compiled assemblies (. Explain the App_Code and Bin shared code folders. showing the Microsoft IntelliSense for the HelloWorld component and the myHelloClass variable. 3.Text = myHelloClass.NET-Based Languages Saturday. . A default class. When you store compiled assemblies in the Bin folder. you can configure your Web application to regard subfolders of the App_Code folder as separate compilable units. Visual Studio prompts you to place the class in the App_Code folder. This demonstration also briefly explains the ASP.cs or Class1.Hello() Button1.aspx. explain the ASP.NET folders.vb.Lab .cs. Rename the class to Hello. Create a new ASP.NET component. When you store source code in the App_Code folder.NET page. open Default. is created. Call the class from an ASP. add a reference to the HelloWorld component.jsl files) that you want to compile as part of your application. Button1.NET page 1.dll file has been copied there. 3. • App_Code.Hello myHelloClass = new HelloWorld.Text = myHelloClass. } [Visual Basic] Function SayHello() As String Return "Hi from Visual Basic .NET Web Site project in Visual C# or Visual Basic." End Function 2. 3. and it will be automatically compiled at run time.dll files) for controls. If time permits.NET-Based Languages página 49 .NET folders and how to add them: • Bin. Show the Class1. September 06. In the Web site. 2. and then click the button. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .SayHello() 4. [Visual C#] public string SayHello() { return "Hi from C# component. .Hello(). and . 2. Add the following code to the Click event procedure. In the Web application. Build the project. Create a SayHello method that returns a string. 3. components. 4. 4. [Visual C#] HelloWorld. Expand the Bin folder in the Web application project and show that the HelloWorld. [Visual Basic] Dim myHelloClass As New HelloWorld. Add a new Class Library project named HelloWorld.vb file. enabling you to use Visual C# and Visual Basic in different sub folders of the App_Code folder. Build and browse Default.aspx in Design view. Place a Button control on the page and create a Click event procedure for it.Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Ensure that Show All Files is selected in Solution Explorer.". Also.

Rather than code the list on every Web page that displays the offered benefits. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . In the labs for this course.NET-Based Languages Exercise 1: Creating an ASP.NET Web Site Scenario Coho Winery offers several benefits to its employees. The list of benefits that Coho Winery offers is displayed on several pages in the Web site. you will create a Web site that enables employees to select and set up their chosen benefits.NET-Based Languages página 50 . you have been asked to develop a component that returns the benefit names.Student Book Content Lab: Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .

and Cobol.Exercise 1 . 5. The runtime uses a JIT compiler to compile the MSIL to native code. September 06. How would you select a . 2. 3. Why would you create a component for a Web application? To share business logic code with other applications. 4. C++. Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Examples include Visual Basic. List three languages that are currently supported by . What role does the common language runtime play in running an ASP.NET Web Site Saturday. What is the role of the JIT compilation? The runtime uses a JIT compiler to compile the MSIL to native code.NET-Based Languages página 51 . The runtime uses a JIT compiler to compile the MSIL to native code. Visual C#. 2008 12:15 AM Instructor Notes (PPT Text) Student Book Content CD Content Review Questions 1.NET.Creating an ASP.NET page? The common language runtime compiles the MSIL to native code and then runs the native code on the server.NET-based language to create a new Web application project? Based on the developer's experience with existing languages. Perl.

NET-Based Languages página 52 .NET Web Site named Benefits.config file requires modification to enable debugging. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. To access the answer key. students will write code to test the Benefits class in a Web page and extend the Benefits class to display an extra benefit. Point out that the Web. Exercise 2 In this exercise. 2008 12:15 AM Instructor Notes (PPT Text) In this lab.Creating a Class Saturday. read the scenario associated with each exercise to the class. Student Book Content Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft . Exercise 1 In this exercise. click the link located at the bottom of the relevant lab exercise page. Note: The lab exercise answer keys are provided on the Course Companion CD. September 06.Exercise 2 . Visual Studio 2008 prompts for this. Remind the students to complete the discussion questions after the last lab exercise. Before the students begin the lab. Debugging is presented in a later module. students will create a component that contains an array that holds the name of a benefit and the name of the Web page that implements that benefit. students will create an ASP. Exercise 3 In this exercise. Make students aware of the differences between debugging and viewing a page in the browser. students will create a class named Benefits that returns a string of names.

NET-Based Languages página 53 . The list of benefits that are offered by Coho Winery is displayed on several pages in the Web site. students have been asked to develop a component that returns the benefit names. 2008 12:15 AM Instructor Notes (PPT Text) Coho Winery offers several benefits to its employees.NET Web Site project for a Benefits Web site that enables employees to select and set up their chosen benefits.Calling the Component Saturday. September 06. In this lab. students will create a Microsoft ASP. Students will create a component that contains an array that holds the benefit name and the name of the Web page that implements that benefit. Rather than code the list on every Web page.Exercise 3 . Student Book Content Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .

Creating Web Forms Saturday. September 06. Module 03-Creating a Microsoft ASP. It also explains how to identify the key characteristics of Web Forms.NET Web Form página 54 . 2008 12:17 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 1 Creating Web Forms This lesson describes how to create a Web Form.

What Is a Web Form Saturday. The file extension determines if ASP or ASP. Web Forms have an . To display a UI.aspx file contains the UI for the Web Form and the . With a traditional Web page.NET Web Form página 55 .aspx. This split between client-side interface and server-side code is a crucial difference between Web Forms and traditional Web pages.aspx Extension Web Forms are commonly referred to as ASP.NET (. code. Module 03-Creating a Microsoft ASP. ASP.NET processes the page. and the page processing remains on the server. and controls that execute on a Web server that is running Microsoft Internet Information Services (IIS). contains the supporting code.aspx extension and are the containers for the text and controls that you want to display on the browser. and the supporting code and controls that run the UI stay on the Web server. However. all of the code is processed at the browser. Web Forms often consist of two separate files: the . Question: What are the key differences in the @ Page attributes for the two types of Web Forms (single file and two file)? CD Content Web Forms consist of a combination of markup.vb or . This UI/code split increases the range of supported browsers and the security and functionality of the Web Form. 2008 12:17 AM Instructor Notes (PPT Text) Student Book Content What Is a Web Form? Key Points The Web Form generates HTML and sends it to the browser. Web Forms send only the interface controls to the browser.aspx.aspx) pages and Active Server Page (ASP) pages can coexist on the same server. Web Forms generate HTML and send it to the browser.cs file. The supporting code and controls that run the UI stay on the Web server. . September 06.NET pages or ASPX pages. This UI/code split increases the range of supported browsers and the security and functionality of the Web page. which is called a code-behind page.

type the name of the Web Form. and then click Add. CD Content You can use two main methods to create a Web Form. right-click the project or Web site name. 2008 12:17 AM Instructor Notes (PPT Text) Use a brief demonstration to illustrate the different ways to create a Web Form. perform the following steps: 1. Student Book Content Creating a Web Form by Using Visual Studio 2008 Key Points To add an additional Web Form to an application. and then click Add New Item. September 06. In the Add New Item dialog box.NET Web Form página 56 . click Web Form. In Solution Explorer. Module 03-Creating a Microsoft ASP.Creating a Web Form by Using Visual Studio 2008 Saturday. 2.

2008 12:17 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 2 Adding Server Controls to a Web Form This lesson describes how to use ASP. and lists.NET server controls such as buttons. These server controls are different from HTML controls in that the supporting logic runs on the server and not on the user's browser.Adding Server Controls to a Web Form Saturday. September 06. text boxes. Module 03-Creating a Microsoft ASP.NET Web Form página 57 .

They include buttons. Another feature of server controls is that the view state. the settings. Server controls include buttons. you determine which event procedures to implement for each server control. You use server controls in ASP. 2008 12:17 AM Instructor Notes (PPT Text) Again.NET server controls are components that run on the server and encapsulate UI and other related functionality.NET code -behind classes. and the user input of the control are automatically saved when the page is sent back and forth between the client and the server. Highlight the round trip to the server that the runat="server" attribute requires. Built-in Functionality The functionality of a control is what happens when the user clicks a button or a list box. <asp:Button id="Button1" runat="server" Text="Submit" /> Runat="server"• Server controls have a runat="server" attribute. Module 03-Creating a Microsoft ASP. These processes are called event procedures. the key point is the runat="server" attribute.What Is a Server Control Saturday. For example you can use this technique to redirect to a mobile Web application when a mobile device is detected. the same attribute as Web Forms. and lists. Student Book Content What Is a Server Control? Key Points ASP. <asp:TextBox id="TextBox1" runat="server" Width="238px" Height="25px">Enter your Username</asp:TextBox> CD Content ASP. text boxes.NET Web Form página 58 . This means that the logic in the control runs on the server and not on the user's browser. Server controls are different from HTML controls.NET server controls are components that run on the server and encapsulate UI and other related functionality. which run only on the client's browser.NET pages and in ASP. As the Web Form programmer. and lists. September 06. Traditional HTML controls are stateless and revert to their default settings when the page returns from the server to the client. mention that it is possible to detect the browser capabilities in the page request and then run appropriate code. During the discussion of the browser-specific HTML. The following is the XHTML that you would write to create a text box with the default text Enter your Username. The following is an example of a Button server control. text boxes.

NET. Question: What types of server controls does your company use in its Web applications? Module 03-Creating a Microsoft ASP. These are broadly divided into HTML server controls and Web server controls. Student Book Content Types of Server Controls Key Points There are many types of sever controls that are available in ASP. 2008 12:17 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on this information.Types of Server Controls Saturday. which gives them additional flexibility. HTML elements on a Web Form are not available to the server. Each option will be reviewed in context in later modules in this course. Web server controls include form-type controls such as buttons and text boxes and also special-purpose controls such as calendars. September 06.NET Web Form página 59 . Mention that students can modify both server-side control types to run client-side code.

Student Book Content Saving View State Key Points View state records the state of controls on a Web Form.0 introduced control state in addition to view state. Saving state is covered in depth in Module 14.NET 2.Saving View State Saturday. Managing State. 2008 12:17 AM Instructor Notes (PPT Text) Do not spend more that the allotted time on this information. September 06.NET Web Form página 60 . ASP. Question: Why is it important to save the state of controls? CD Content Module 03-Creating a Microsoft ASP. View state can be disabled at the page level and enabled for individual controls.

Module 03-Creating a Microsoft ASP. CD Content HTML controls on a Web Form are not available to the server.NET Web Form página 61 . This conversion enables you to use the controls to trigger events that are handled on the server. By converting HTML controls to HTML server controls. HTML server controls include the runat="server" attribute. September 06. This conversion enables you to use the controls to trigger events that are handled on the server. 2008 12:17 AM Instructor Notes (PPT Text) Explain that students can convert HTML controls to HTML server controls to make them available to the server. you can expose them as elements to your server-side code. Student Book Content HTML Server Controls Key Points HTML server controls can be exposed as elements to your server-side code.HTML Server Controls Saturday.

perform a quick demonstration of some of these controls. Validation controls are hidden controls that validate the user's input against predetermined patterns. Explain that all controls share common attributes. button and list box. If you have time. Add some of the more common intrinsic controls to a page. Module 03-Creating a Microsoft ASP. list -bound and login. Do not go into too much detail when you present the sections on validation controls and list -bound controls because these are covered in more depth in later modules. List-bound controls can display data from a data source. September 06. for example the id attribute. rich. validation. Cover several of the key standard controls such as text box. 2008 12:17 AM Instructor Notes (PPT Text) Cover the different types of controls: intrinsic.Web Server Controls Saturday. Display the page in the browser and view the source of the page. Rich controls provide a rich functionality to your Web Form by inserting complex functions into your Web Form.NET Web Form página 62 . Student Book Content Web Server Controls Key Points Intrinsic Web server controls correspond to simple HTML elements.

Student Book Content Validation Controls Validation controls are hidden controls that validate the user's input against predetermined patterns. During the discussion. use the code provided in the article at http://go. Control CompareValidator Function Requires that the input matches a second input or existing field. 2008 12:17 AM Instructor Notes (PPT Text) Discuss with the students situations where they might use HTML or Web server controls. Requires that the input match a specified range. as stated in the module the HTML DOM is not as capable as the programming model behind ASP. the use of the HTML document object model (DOM). Module 03-Creating a Microsoft ASP. Discuss which of the reasons to use HTML controls might be the most important (for example.NET Web server controls.S. CustomValidator RangeValidator Requires that the input match a condition such as prime or odd numbers. If students express an interest in how to add client script to Web server controls. The following table describes some of the commonly used validation controls. RegularExpressionV Requires that the input matches a specified format such as a U.Discussion . or ValidationSummary Collects all of the validation control error messages for centralized display. September 06.Selecting the Appropriate Control Saturday.) However.com/fwlink/?LinkId=110688 to provide a brief demonstration. telephone number or a alidator strong password with numbers and letters.microsoft. RequiredFieldValidat Requires that the user enters some value before the control is processed.NET Web Form página 63 . emphasize that the best practice is to avoid HTML server controls.

Control Calendar Menu Function Displays a graphic calendar on which users can select dates. List Repeater Displays information from a data set by using a set of HTML elements and controls that you specify.NET Web Form página 64 . TreeView Wizard Displays hierarchical data (such as a table of contents or file directory) in a tree structure. Similar to the Repeater control but with more formatting and layout options. st CheckBox Displays data as a column of check boxes. The following table describes several of the presently available rich controls. insert. Displays both static and dynamic menus. The Repeater control repeats the element once for each record in the data set. The DataList control also allows you to specify editing behavior. AdRotator Displays a sequence (predefined or random) of images. DataList Displays information from a data set. and business objects that expose data. ListBox Displays data in a window. List GridView Displays information from many different kinds of data sources. Implicitly supports edit. The following table describes some of the commonly used list-bound controls. Provides navigation and a UI to collect related data across multiple steps. and delete operations in addition to sorting and paging functionality. List-Bound Controls List-bound controls can display data from a data source. September 06. including databases. RadioButt Displays data as a column of option buttons. onList Module 03-Creating a Microsoft ASP. including the ability to display information in a table. Control Function BulletedLi Displays a list of items in a bulleted format.Creating Master Pages Saturday. DropDown Displays data as a drop-down list. 2008 12:17 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Rich Controls Rich controls provide a rich functionality to your Web Form by inserting complex functions into your Web Form. ListView Displays data in a format that you define by using templates and styles. XML files.

NET Web Form página 65 .Module 03-Creating a Microsoft ASP.

What Are Master Pages Saturday. 2008 12:17 AM Instructor Notes (PPT Text) Discuss the key features of master pages. Student Book Content Module 03-Creating a Microsoft ASP. Ensure that the students understand that the purpose of master pages is to simplify the process of creating a Web site that has a consistent layout. September 06.NET Web Form página 66 .

click Master Page. the child master page also has its own content placeholders. 2008 12:17 AM Instructor Notes (PPT Text) Explain how the content page references a master page and describe the steps required to create a content page. These placeholders display content supplied by the child's content pages or further child master pages. b) In the Name box. and then click Add. Student Book Content The child master page contains content controls that map to content placeholders on the parent master page. right-click the project. September 06. In Solution Explorer.Content Pages Saturday. use the following steps. Module 03-Creating a Microsoft ASP. To create a master page To create a master page. and then click Add New Item. In addition.NET Web Form página 67 . In the Add New Item dialog box: a) In the Templates pane. 2. 1. type a name for the new page.

ASP. September 06.NET renders the final merged page to the browser.NET Web Form página 68 . CD Content Module 03-Creating a Microsoft ASP.Runtime Behavior of Master Pages Saturday. ASP. ASP. The user types the URL of the content page to request the page. If the directive contains a MasterPageFile attribute. 3. 4. 2008 12:17 AM Instructor Notes (PPT Text) Describe the process that takes place when a user requests a content page from a browser.NET retrieves the master page. ASP. Student Book Content Runtime Behavior of Master Pages Key Points The full process of the runtime behavior of master pages is as follows: 1.NET reads the @ Page directive of the content page. 2.NET merges the master page content into the control tree of the content page.

Discussion .Advantages of Master Pages Saturday. 2008 12:17 AM Instructor Notes (PPT Text) Discuss the advantages of master pages. September 06.NET Web Form página 69 . Module 03-Creating a Microsoft ASP. Student Book Content Discussion: Advantages of Master Pages Key Points There are several advantages of master pages. Question: What are some of the advantages of master pages? CD Content There are several advantages of master pages. By using master pages you can: Improve the maintenance of Web sites because you can make updates in one place that affect all of the pages in that Web site.

Before the students begin the lab.NET Web Form página 70 . students create the life. September 06. In the labs for this course. Note: The lab exercise answer keys are provided on the Course Companion CD. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. students create a master page for the Benefits Web application. read the scenario associated with each exercise to the class. students will create a Microsoft ASP. students create a Microsoft ASP.Lab . Exercise 3 In this exercise. Module 03-Creating a Microsoft ASP. Remind the students to complete the discussion questions after the last lab exercise.aspx Web Form Scenario Coho Winery offers several benefits to its employees. 2008 12:17 AM Instructor Notes (PPT Text) In this lab. To access the answer key. click the link located at the bottom of the relevant lab exercise page.NET Web Form and populate it with Web controls. Exercise 1 In this exercise.NET Web Form Saturday. Exercise 2 In this exercise.Creating a Microsoft ASP. you will create a Web site that enables employees to select and set up their chosen benefits.NET Web Form Exercise 1: Creating the Default.NET Web Form.aspx Web Form. Student Book Content Lab: Creating a Microsoft ASP.

and a Label control to the Default. Student Book Content 5.Creating the Default.Exercise 1 . 8. 2008 12:17 AM Instructor Notes (PPT Text) Coho Winery offers several benefits to its employees.aspx page. Save the Default. birth date. The life. a Button control. 6. 7. 9.aspx Web Form. The default.aspx Web Form is the home page for the Benefits Web site. Close the browser window. View the Default. In this lab. Module 03-Creating a Microsoft ASP. and coverage amount .NET Web Form página 71 . Ensure that the items in the CheckBoxList control are correctly displayed.aspx and life. The default.aspx Web Form allows users to enter life insurance information such as their name.aspx page in the browser. you have added a user control. a list-bound control. September 06.aspx Web Form Saturday.aspx Web Form pages in the Benefits Web application. Click OK to close the ListItem Collection Editor dialog box and save the new items. Results:After this exercise.aspx Web Form displays the list of benefits that are offered by the company. students will create the user interface (UI) of the default.

NET Web Form página 72 .jpg in the left hand cell of the table on the benefitsMaster page. use a drag-and-drop operation to place the file RedWine. In the Accessibility Properties dialog box. 2.master page in Design view. which must be displayed on several pages in the Web site. 2008 12:17 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. This page contains a header and a logo. Add the file E:\Labfiles\Starter\RedWine.jpg to the Images folder in the Benefits Web site. In the benefitsMaster. Create the master page. The main tasks for this exercise are as follows: 1. What content in the life. which you must add to the Benefits Web site. 1. Module 03-Creating a Microsoft ASP. 7.master. 1. 2. 3. 6. 3.jpg. Student Book Content Exercise 2: Creating the benefitsMaster Master Page Scenario In this exercise. 4. Use the Table menu to insert a one row. 2. in the Alternate text box. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. Create a subfolder named Images in the Benefits Web site. Task1: Create the master page Create a new master page named benefitsMaster. Open the benefitsMaster. before the ContentPlaceHolder container on the page. Which other pages in the application can use the master page? Default and medical. 5.aspx page comes from the master page? The header control and the red wine logo. What categories of server controls are used in the lab? Intrinsic and rich.master page. 8. Add items to the master page.jpg image to 35 pixels wide and 60 pixels high.Creating the benefitsMaster Master Page Saturday.Exercise 2 . The logo is stored in the file RedWine. September 06. Task2: Add items to the master page The master page will contain a header and a logo. type Coho Winery logo and then click OK. Set the height and width of the RedWine. In Solution Explorer. click at the very start of the page. two column HTML table on the master page. You will place these items inside a table on the master page. you will create a master page for the Benefits Web site.

The life. and fifth rows. On the Table menu.aspx Web Form Task1: Create the life. You can create high-level hints for each scenario by using the following possible solutions for the scenarios. 3. click Insert Table. In Design view.aspx page. insert a carriage return.aspx Web Form You will use a table to define the layout of the controls on the life. Best Practices Help the students understand the best practices presented in this section. Ask students to consider these best practices in the context of their own business situations. click the life. 1.aspx Web Form. Create a table that has 9 rows and 3 columns. 2. drag controls into the table as follows: a) In the first column of the table.aspx Web Form 2. you should provide some high-level hints that might help the students solve the problem stated in the scenarios.master as its master page. September 06. In the ContentPlaceHolder1 container. inside the ContentPlaceHolder1 container.aspx page in Design view. The main tasks for this exercise are as follows: 1. 4. Task2: Add controls to the life. How can you do this? In Solution Explorer. b) In the second column of the table. drag a Label control into the first row. click Add New Item. fourth. Drag TextBox controls into the Module 03-Creating a Microsoft ASP.aspx Web Form Create a new Web Form named life.aspx Web Form.Exercise 3 .aspx page will use the file benefitsMaster. 6. 2008 12:17 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. Create the life. Add controls to the life. Drag a CheckBox control into the seventh row and a Button control into the ninth row.NET Web Form página 73 . • You want to share content among multiple pages in a Web application. This page implements the life insurance benefit for your company. right-click the project or Web site name. What is the best approach and why? Use a master page because it gives your application a consistent layout. Open the life. 5. you will create the UI for the life.aspx that uses the benefitsMaster file as its master page. drag Label controls into the third. • You want to add a Web Form to your Web site. and then use the Add New Item dialog box to add a new Web Form to your Web site. In the Toolbox.aspx Web Form Saturday.Creating the life. You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students.aspx Web Form Scenario In this exercise. Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students. If you assign the scenarios as homework. Student Book Content Exercise 3: Creating the life.

Module 03-Creating a Microsoft ASP. and fifth rows. drag a Label control into the first row. Drag TextBox controls into the third. fourth. Drag a CheckBox control into the seventh row. select the cells in rows 4 to 8. drag a Label control into the third row.NET Web Form página 74 .b) In the second column of the table. d) In the third column of the table. c) In the third column of the table.

NET Web Form página 75 .aspx file. or in a separate file. September 06.Implementing Code-Behind Pages Saturday. Inline code uses HTML and code in separate sections of a single . This lesson explains how to implement code with Visual Studio 2008. in a separate SCRIPT section of the same file. 2008 12:19 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 1 Implementing Code-Behind Pages You can add code to your Web Form in the same file as the Web content. Code-behind pages contain all of the programming logic for a single Web page. It also explains how to use code -behind pages and how they are different from inline code. Module 04-Adding Code to a Microsoft ASP.

The code is in a separate SCRIPT section of the same file as the HTML content. Question: . Inline code. 2008 12:19 AM Instructor Notes (PPT Text) This topic focuses on the difference between inline code and code-behind pages. Code-behind.What are the advantages and disadvantages of each method? Module 04-Adding Code to a Microsoft ASP. The code is in the same file as the Web content. September 06.Methods for Implementing Code Saturday. The code is in a separate file from the HTML content.NET Web Form página 76 . Student Book Content Methods for Implementing Code Key Points You can add code to your Web Form in the following three ways: Mixed code.

Inline code places HTML and code in separate sections of a single . Module 04-Adding Code to a Microsoft ASP. 2008 12:19 AM Instructor Notes (PPT Text) This slide provides a contrast between inline code and code-behind pages. especially pages that were developed for ASP. September 06.Writing Inline Code Saturday. Emphasize that if the students write inline code.aspx Web Form. Also explain that the separation in the file is for clarity only. the code is directly inserted in the . especially pages that were developed for ASP.aspx file. you may encounter pages that use inline code. CD Content Although the default method for implementing server-side code in Visual Studio 2008 is to use a code-behind page. the code and HTML can exist anywhere on the page.NET Web Form página 77 . Student Book Content Writing Inline Code Key Points You may encounter pages that use inline code. This separation is for clarity.

What Are Code-Behind Pages Saturday. enabling developers and designers to work simultaneously. September 06.NET Web Forms. The code-behind page has an .vb or .NET Web Form página 78 . CD Content Module 04-Adding Code to a Microsoft ASP. The programming logic for a Web page is in a separate file than the visual elements of the page. by default. 2008 12:19 AM Instructor Notes (PPT Text) Emphasize that the use of code-behind pages is the default way to write code for ASP. uses code-behind pages to implement server-side code. Student Book Content What Are Code-Behind Pages? Key Points Visual Studio 2008. Each Web page in a Web application has its own code-behind page.cs extension.aspx.aspx.

The . You must you the Src attribute in conjunction with the @Register directive for user controls. Question: What are the benefits and drawbacks of JIT and precompilation? Module 04-Adding Code to a Microsoft ASP." Student Book Content How Code-Behind Pages Work Key Points For code-behind pages. precompiles code-behind pages.aspx page must be associated with a code-behind page. by default. each . 2008 12:19 AM Instructor Notes (PPT Text) Explain that the association between the files is important and that a code-behind page must be compiled before it is run.How Code-Behind Pages Work Saturday. "Creating and Implementing User Controls.NET Web Form página 79 . Visual Studio 2008.aspx page and the code behind page form a single unit when the Web application is run. and that code-behind page must be compiled before information is returned to a requesting client browser. which implies they are JIT compiled. this saves considerable processing and simplifies the deployment of the Web site. This point can be made and expanded on in Module 7. September 06. Ensure students are comfortable with the difference between pre-compilation and just-in-time (JIT) compilation.

It enables you to distinguish between the two types of events (server-side and client-side) and decide when it is appropriate to use each type. September 06.NET Web Form página 80 . Server-side event procedures require information to be sent to the Web server for processing and are much more powerful than client-side event procedures. There are two types of event procedures: client-side and server-side. 2008 12:19 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 2 Adding Event Procedures to Web Server Controls You can use event procedures to handle user interactions on a Web Form. Module 04-Adding Code to a Microsoft ASP. Client-side event procedures are events that are handled on the computer that requests the Web Form.Adding Event Procedures to Web Server Controls Saturday. This lesson describes event procedures and explains how to add them to Web server controls.

interactive Web Forms typically react to user input.NET Web Form página 81 . Module 04-Adding Code to a Microsoft ASP. CD Content Dynamic. 2008 12:19 AM Instructor Notes (PPT Text) Explain event handling so that students can understand why it is important.What Are Event Procedures Saturday. interactive Web Forms typically react to user input. You can use event procedures to handle user interactions on a Web Form. September 06. An event procedure is the action that occurs in response to the generated event. Student Book Content What Are Event Procedures? Key Points Dynamic. Event procedures handle user interactions on a Web Form.

Student Book Content Client-Side Event Procedures Key Points Client-side event procedures are events that are handled on the computer that requests the Web Form (the client). for example. validation events. When an event is generated. You can specify a client-side event procedure by creating a <SCRIPT> block in the Web page. Explain that the language for client script can be either Javascript or VBScript. Client-side event procedures are useful for events that you want to happen immediately because they do not require a round trip to the Web server.Client-Side Event Procedures Saturday. 2008 12:19 AM Instructor Notes (PPT Text) Client-side event procedures are useful for events that must happen immediately. Note: When you ask the question in the student workbook.NET AJAX at this point.NET Web Form página 82 . don't be tempted to launch into a discussion on ASP. no information is sent to the server. Question: What are the advantages and disadvantages of client-side event procedures? Module 04-Adding Code to a Microsoft ASP. September 06.

Server-side event procedures cannot support events that occur frequently such as mouse-key events. consist of compiled code that resides on the Web server. Module 04-Adding Code to a Microsoft ASP.Server-Side Event Procedures Saturday. The key difference is runat="server". Student Book Content Server-Side Event Procedures Key Points Server-side event procedures are much more powerful than client-side event procedures.NET Web Form página 83 . You can use server-side event procedures to handle events that are generated from both Web and HTML server controls. and require information to be sent to the Web server for processing. 2008 12:19 AM Instructor Notes (PPT Text) Client-side event procedures are more powerful than client-side event procedures. September 06.

Module 04-Adding Code to a Microsoft ASP. you will see how client-side and server-side event procedures are processed on the client and on the server.NET page from the Web server.Multimedia .NET Web Form página 84 . 2. The server returns a page containing HTML and script to the client. CD Content In this animation. The page also contains client-side script that validates the contents of the text box. September 06. The client requests an ASP. The page includes a text box control and a Submit button.Client-Side and Server-Side Events Saturday. 1. you will see how client-side and server-side event procedures are processed on the client and on the server. 2008 12:19 AM Instructor Notes (PPT Text) Student Book Content Multimedia: Client-Side and Server-Side Events Key Points In this animation.

there are significant differences behind the scenes. Visual Studio 2008 creates an event procedure template: In Microsoft Visual C# ®. Student Book Content Creating Event Procedures Key Points To create a server-side event procedure in Visual Studio 2008. you must perform two steps: 1. September 06. Module 04-Adding Code to a Microsoft ASP.Creating Event Procedures Saturday.NET Web Form página 85 . Create the control that generates the event on the Web Form. Provide the code on the code-behind page that handles the event. 2008 12:19 AM Instructor Notes (PPT Text) The answer to the topic question can be simple or quite complex. but the process is essentially the same. When you double-click a control in Visual Studio 2008. 2. the onclick attribute is set to the name of the event procedure.

. 3.Demonstration . You can perform this demonstration by using either Visual C# or Microsoft Visual Basic®. For a Visual C# demonstration.NET Web Form página 86 . In the code-behind page.. Open Visual Studio 2008. Create a Web site. In Design view. [Visual C#] . and then click View in Browser.. There is just server-side code. [Visual Basic] Label1.. In Solution Explorer. In the browser. 2.Text = "You clicked the button". • Add controls to the Web Form 1. Student Book Content Module 04-Adding Code to a Microsoft ASP. notice the Handles keyword in the Button1_Click event procedure. The text of the label changes. view the source of the page to show that there is no client -side code. System. double-click the Button control to open the code-behind page and create a Click event procedure.EventArgs e) { } [Visual Basic] Sub Button1_Click(ByVal s As Object. 4. 2. examine the default properties of the controls. Add a Web Form to the Web site or use the Deafult. 2008 12:19 AM You can use this demonstration throughout the lesson to illustrate the different topics to students as you talk about them. [Visual C#] protected void Button1_Click(object sender. 3. Instructor Notes (PPT Text) • Browse the page 1. In the Properties window. Add the following code in the Click event procedure. 2. In this demonstration.Creating an Event Procedure Saturday. Close the source view of the page. click the button on the form. 5. the procedure is bound to the event procedure by adding the attribute onclick to the markup. For a Visual Basic demonstration. ByVal e As EventArgs) Handles Button1. The following code illustrates this. 2. notice the event procedure template that is created by Visual Studio 2008.. September 06. [Visual C#] Label1.aspx page which is automatically added. • Create a Web Form by using Visual Studio 2008 1. Add a Button and a Label control to the form. In the browser. right-click the Web Form.Text = "You clicked the button" 4. • Add a Click event procedure 1. students will see how to add an event procedure to a Web control by using Visual Studio 2008.Click End Sub 3.

Student Book Content Demonstration: Creating an Event Procedure Question: How can you create a default event procedure for a control? CD Content In this demonstration. the instructor will show you how to create an event procedure for a button on a Web page that changes the text of a label.NET Web Form página 87 . Module 04-Adding Code to a Microsoft ASP.

You can do this in server-side event procedures. 2008 12:19 AM Instructor Notes (PPT Text) Student Book Content Interacting with Controls in Event Procedures Key Points In many Web applications. Question: What are some key properties of a Web server control? Module 04-Adding Code to a Microsoft ASP. you must read from and write to controls on a form. You can output information directly to a Web server control by using the control's properties. you can read information from a server control.Interacting with Controls in Event Procedures Saturday. In a server-side event procedure. September 06.NET Web Form página 88 .

You can also link one control to the contents of another. Student Book Content Lesson 3 Handling Page Events The page event life cycle is the series of page events that occur when an ASP. You will also see how to work with the Page_Load event and link controls together. 2008 12:19 AM Instructor Notes (PPT Text) Explain to the students that it is common to read from and write to controls on a form. for example. Module 04-Adding Code to a Microsoft ASP. September 06. This lesson explains how to use page events. It introduces the page event life cycle and describes the postback process and event order. Explain that they can accomplish this with event procedures.NET Forms post information back to the sending ASP.NET Web Form página 89 . to display values from list boxes or drop-down lists.NET page for processing.Handling Page Events Saturday.IsPostBack property to control which code executes only when the page is initially requested. You can use the Page. Postbacks are when ASP.NET page is requested.

September 06. 2.NET Web Form página 90 . Page_Unload. 2008 12:19 AM Instructor Notes (PPT Text) Lesson overview Student Book Content The Page Event Life Cycle Key Points When an ASP. Occurs when the page is closed or when the control is passed to another page. which is referred to as the page event life cycle.NET page is requested. Page_Load. Module 04-Adding Code to a Microsoft ASP. and then action events. Runs every time the page is requested. 1. 4. Page_Init. there are a series of page events that occur. Consist of change events. Initializes the page by creating and initializing the Web server controls. Control events.The Page Event Life Cycle Saturday. These events always occur in the same order. 3.

The first time that a user requests a page from the server. Module 04-Adding Code to a Microsoft ASP. In this example. how you can code the Page_Load event. CD Content In this animation. September 06. you will see how Forms work in ASP.Multimedia . 2008 12:19 AM Instructor Notes (PPT Text) The slide does not list all of the available page events.The PostBack Process Saturday.NET. Student Book Content Multimedia: The PostBack Process Key Points In this animation.NET and how the Page_Load event can be coded to run only the first time a page is displayed. the code populates a list box. you will see how Forms work in ASP. Cover several of the key events. Make students aware that page events may not come back in the order that they were coded. the test for Page.NET Web Form página 91 . and how controls can be made to post immediately to the server.IsPostBack in the Page_Load event succeeds and the code in the block runs. and how you can make controls post immediately to the server.

Demonstration . 2008 12:19 AM Instructor Notes (PPT Text) This multimedia explains how Forms work in ASP.Handling Events Saturday. the instructor will show you how HTML and Web server controls can support both client-side and server-side events.NET. Module 04-Adding Code to a Microsoft ASP. Student Book Content Demonstration: Handling Events Question: How can you change an HTML control to a Web server control? CD Content In this demonstration. September 06.NET Web Form página 92 .

onserverclick. The following code illustrates this. click a value in the Profession list. and onserverchange attributes are not recognized by the syntax checker. View the page in the browser again. add a Text attribute to the HTML code of the check box to change it into a Web server control. you can leave them in the code.NET Web Form página 93 . In the EventOrderStart. View the page in the browser again. the server event does not run because the name of the server event is oncheckedchange. Type a name in the Name box. check box. • Implement a Page. 7. not onserverchange. and then click Save. <asp:checkbox onclick="checkClick()" onserverclick="checkServerClick" onserverchange="checkServerChange" runat="server" id="Checkbox1" Text="Certified Professional"/> Note: Although the onclick. and then click Save. Note: The EventOrderFinal. 3. View the page in a browser. Edit the page in HTML view and change the name of the server-side event procedure attribute from onserverchange to oncheckedchanged. Enter a name in the Name box.Handling Page. 5. list box.aspx file in the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder contains a complete solution for this demonstration.IsPostback Events Saturday. and the page. Instructor Notes (PPT Text) onserverclick="checkServerClick" oncheckedchanged="checkServerChange" runat="server" id="Checkbox1" Text="Certified Professional"/> 5. Type a name in the Name box. click a value in the Profession list. 2. Edit the page and set the AutoPostBack attribute to true for the check box. select the check box. click a value in the Profession list. • Change a check box to a Web server control 1. 4. select the check box. The following code illustrates this. The check box fires only client-side events now. You can perform this demonstration by using either Visual C# or Visual Basic. 6. students will see how link a Label control to a ListBox control and bind data to the Label control. In Visual Studio 2008. create a Web site in Visual C# if you do not already have one open. Although the client event still runs because generates . • View the page 1.IsPostBack test 1. Add the EventOrderStart. 3. Module 04-Adding Code to a Microsoft ASP. 4. and then click Save. Close the browser. select the check box. 2. The page has client-side and server-side event procedures for the text box. 2. button. View the page in the browser again. 2008 12:19 AM In this demonstration. September 06.aspx page. Both client and server event procedures run again.aspx page from the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder to the Web site.

4. When you use postback events. the client-side event fires and then the server-side event fires. Close the source view page.IsPostBack property to control which code executes only when the page is initially requested. you can use the Page. whether it is the first request of the page or a postback. View the page in the browser again. 5.2. Student Book Content Handling Page. 3. whether it is the first request of the page or a postback. In the browser. if you do not want all of the code to execute again. Cross-page posting is the process of posting one Web page to another page. When you select the check box. view the source of the page to see how AutoPostBack is implemented.NET Web Form página 94 .IsPostback Events Key Points The Page_Load event runs on every request for a page. CD Content The Page_Load event runs on every request for a page. Module 04-Adding Code to a Microsoft ASP.

You can use the DataBind method of either the entire page or just a control. CD Content You can link one control to the contents of another. <asp:Label id="selectedValueLabel" runat="server" Module 04-Adding Code to a Microsoft ASP.NET Web Form página 95 . Linking controls is particularly useful when you want to display values from list boxes or drop-down lists. The following code example demonstrates how to link a Label control to the contents of a drop-down list.Linking Two Controls Together Saturday. You can use the linking tags <%# and %> to set the Text attribute of a Label control to the SelectedItemof the list box. September 06. 2008 12:19 AM Instructor Notes (PPT Text) Student Book Content Linking Two Controls Together Key Points You can link one control to the contents of another. Linking controls is particularly useful when you want to display values from list boxes or drop-down lists.

Cross-page posting can be considered an advanced topic that is beyond the scope of this course. September 06. A suitable reference is provided.Demonstration . Student Book Content Demonstration: Linking Controls Together Question: Why is the label updated every time you select a profession? CD Content In this demonstration.NET Web Form página 96 .Linking Controls Together Saturday. so direct students to this resource for further information. 2008 12:19 AM Instructor Notes (PPT Text) The key point for students to understand is that their application must check if the page is being loaded in response to a client postback or is being loaded and accessed for the first time. the instructor will show you how to link controls together. Module 04-Adding Code to a Microsoft ASP.

aspx page of your company's Web site. Student Book Content Lab: Adding Functionality to a Web Application Exercise 1: Creating a Page_Load Event Procedure Scenario Coho Winery offers several benefits to its employees. 2008 12:19 AM Instructor Notes (PPT Text) Discuss with the students when it is useful to link controls together. In the labs for this course. In the first lab. Module 04-Adding Code to a Microsoft ASP. you created a component that returned a list of all the benefits that are offered by your company. Use the following demonstration to illustrate the key points as you talk about them. display the information in a CheckBoxList control. and implement a Submit button on the form to display which benefits are selected. you will call that component from the Default. September 06. you will create a Web site that enables employees to select and set up their chosen benefits.Lab .NET Web Form página 97 . In this lab.Adding Functionality to a Web Application Saturday.

but the data is bound in the titleList_SelectedIndexChanged event procedure.DataBind() 6. The following code example illustrates this. 2008 12:19 AM Instructor Notes (PPT Text) • • • • In this demonstration.aspx page from the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder to the Web site. View the controls 1. note that the onclick attribute is added automatically. The following code example illustrates this. [Visual Basic] listValueLabel. If the demonstration is in Visual C#. In the Page_Load event procedure. Module 04-Adding Code to a Microsoft ASP. Create a Page_Load event procedure for the page. call listValueLabel. [Visual Basic] listValueLabel. 3. When you select an item in the DropDownList.DataBind().NET Web Form página 98 . September 06.Exercise 1 . add the BindingStart. 2. Create a SelectedIndexChanged event procedure for the titleList control. 4.aspx page in a browser. Build the Web site and view the BindingStart. [Visual C#] listValueLabel. students will see how HTML and Web server controls can support both clientside and server-side events. In Visual Studio 2008. Note: The BindingF inal.DataBind(). create a Web site if you do not already have one open. Why would you want to set up your code-behind pages to be precompiled instead of JIT compiled? If you precompile all the code for a Web application. Text=" runat="server"/> Bind data to the Label control 1.aspx file in the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder contains a complete solution for this demonstration. the value is reflected in the Label control. Build the Web site and view the BindingStart.DataBind(). 2. There is a DropDownList and a Label control on this page. Delete the code that you added to the Page_Load event procedure.Creating a Page_Load Event Procedure Saturday.aspx page in a browser. The following code example illustrates this. 3. 5. View the HTML for the page. 4. 2. When you select an item in the DropDownList. 5. Note the AutoPostBack attribute for the DropDownList control.DataBind() Build and browse 1. it saves time and resources on the Web server because the server does not have to compile the pages as they are accessed. call listValueLabel. 7. Depending on the language chosen. In the titleList_SelectedIndexC hanged event procedure. [Visual C#] listValueLabel. the value is again reflected in the Label control.DataBind(). Student Book Content 4. Link a Label to a ListBox control • Link the Label control to the DropDownList control by setting the Text attribute of the Label control. When does a form post back to itself? When the user clicks a button on a server form or a control with AutoPostBack set to True.

NET Web Form página 99 .Module 04-Adding Code to a Microsoft ASP.

Remind the students to complete the discussion questions after the last lab exercise. students create Click event procedures for Web controls on an ASP. students create a Page_Load event procedure for a Microsoft ASP. Exercise 1 In this exercise. students will add functionality to a Web application by using event procedures. September 06. Exercise 2 In this exercise. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. click the link located at the bottom of the relevant lab exercise page. Note: The lab exercise answer keys are provided on the Course Companion CD.NET Web page. Before the students begin the lab.NET Web Form página 100 . Student Book Content Module 04-Adding Code to a Microsoft ASP. To access the answer key.NET Web page. 2008 12:19 AM Instructor Notes (PPT Text) In this lab. read the scenario associated with each exercise to the class.Exercise 2 .Creating a Click Event Procedure Saturday.

2008 12:19 AM Instructor Notes (PPT Text) In the first lab.NET Web Form página 101 . display the information in a CheckBoxList control. students will call that component from the Default.(If Time Permits) . Student Book Content Module 04-Adding Code to a Microsoft ASP. September 06.aspx page of the company's Web site. and implement a Submit button on the form to display which benefits are selected.Exercise 3 .Implementing a Component in a User Control Saturday. In this lab. students created a component that returned a list of all the benefits that are offered by the Coho Winery company.

Visual Studio 2008 offers two objects for gathering such information at run time: the Debug object and the Trace object. These informative messages from the Web application can help you to diagnose problems or analyze performance. September 06.NET Web Applications página 102 .Tracing and the Trace Object Saturday. 2008 12:21 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Tracing and the Trace Object Tracing is the process of receiving informative messages about the execution of a Web application at runtime. This lesson describes how to use the Trace object to implement tracing in a Web application. Module 05-Tracing in Microsoft ASP.

2008 12:21 AM Instructor Notes (PPT Text) Check that the students are familiar with the concept of debugging.Run Time Information Saturday. A note at the end of the topic mentions that students must import the System. For example. Question: When have you used tracing or debugging in your own applications? CD Content You can collect information while your Web application runs by using the Debug and Trace objects. The Trace object in Microsoft ASP. Module 05-Tracing in Microsoft ASP. It is important to make this point because the students may already be familiar with debugging features and the use of the Debug object for Microsoft® Windows®-based application development. where the reference is added automatically. September 06. Refer them to the additional content provided on the Course Companion CD if they want to refresh their knowledge. You can follow the programming logic of a Web Form while it executes to ensure that processing occurs properly. Types of Information You can perform the following steps during runtime: Output values of variables.Diagnostics namespace to use the Debug object.NET enables you to display information on a Web page or save it in memory. Follow the execution path of the application.NET Web Applications página 103 . Run Time Objects You can use two objects to display debugging information during runtime. the Trace. Those objects are: The Trace object.WriteIf method outputs a message if a condition is met. Student Book Content Run Time Information Key Points You can collect information while your Web application runs by using the Debug and Trace objects.NET enables you to display information on a Web page or save it in memory. Ensure that the students understand the difference between the Trace and Debug objects. Determine if certain conditions have been met. Statements that use the Debug object run only when they are compiled in debug mode and when the Web application is run in the debugger. The Trace object in Microsoft ASP.

config file with this slide. The pageOutput attribute of the trace element specifies where the messages are written. you can write trace statements directly to the page or to a storage object. all trace messages are appended to the end of the Web page. 2008 12:21 AM Instructor Notes (PPT Text) Discuss the web. It is important for you to establish the importance of camelCase. Student Book Content Enabling Tracing Key Points When you use tracing. ensure you mention that it is in XML format and is case sensitive. With application-level tracing.Enabling Tracing Saturday. you can write trace messages to the page or to memory. September 06. Question: Why may you want trace statements to be visible only on the local computer? Module 05-Tracing in Microsoft ASP. When you use page-level tracing.NET Web Applications página 104 .

To check whether tracing is enabled or to turn tracing on and off.Write but displays messages in red. 2008 12:21 AM Instructor Notes (PPT Text) Mention Trace. you provide a message to be written and optionally a corresponding category for the message.IsEnabled property.Warn and explain that it works identically to Trace. CD Content Module 05-Tracing in Microsoft ASP.Warn methods. September 06.The Trace Object Saturday.NET Web Applications página 105 . you use the Trace. To use the Write and Warn methods. you can use the Trace. Student Book Content The Trace Object Key Points To write trace messages on a page (or in memory).Write and Trace.

September 06. [Visual C#] if (Trace.IsEnabled There are situations when you may want to generate trace messages only when tracing is enabled for a Web page or Web application. } [Visual Basic] If Trace. Trace. The following code illustrates this. For these situations.Write("myTrace". The following code illustrates this.IsEnabled Then message = "Tracing is enabled!" Trace.Viewing Trace Results Saturday.Write("myTrace". Module 05-Tracing in Microsoft ASP. the Trace object has a Boolean property named IsEnabled that enables you to call the Write and Warn methods only when tracing is enabled. message) End If You can also use the IsEnabled property to change the state of tracing for a page dynamically.NET Web Applications página 106 . message).IsEnabled) { message = "Tracing is enabled!". Trace. 2008 12:21 AM Instructor Notes (PPT Text) Briefly discuss the different categories of trace results that may appear on a Web page. Student Book Content The resulting trace messages appear as shown in the following illustration.

config file. they should disable the trace viewer.NET Web Applications página 107 . advise the students that page-level tracing overrides any other trace setting. September 06.config file that is in the machine configuration folder. Question: What is the advantage of the application-level trace viewer over displaying trace information on the page? CD Content Module 05-Tracing in Microsoft ASP.Application-Level Trace Saturday. 2008 12:21 AM Instructor Notes (PPT Text) To summarize the trace settings. Student Book Content Application-Level Trace Key Points You enable application-level tracing in the web. you can view trace statements on individual pages or in the trace viewer. You can disable the trace viewer for a Web server by editing the web. Inform the students that if they are particularly concerned about security. After application-level tracing is enabled.

aspx page and note that trace messages are not displayed because trace is explicitly turned off for this page. This allows only local browsers to see trace information.Text). [Visual Basic] Trace. September 06. 6.Write("Shipping". the trace can be viewed from a different computer. No trace messages are shown on the page. To run the demonstration 1. [Visual C#] Trace. Instructor Notes (PPT Text) Module 05-Tracing in Microsoft ASP. Notice that the localOnly attribute is set to true (this is also the default value).aspx page in the click event procedure for Button1.Close the browser window.Warn("Double It". Change the trace tag in the web. 2. [Visual C#] Trace. Enter a price.aspx page in the browser. Explain that the localOnly attribute specifies who can see the trace and that when the pageOutput attribute is set to false. by including the Trace attribute in the @ Page directive. View the Numbers.aspx page. Turn tracing on at the application level by adding the trace tag to the web.Write("Shipping". "shipping cost = " + Convert.ToString(shippingCost)). and then click Calculate Shipping. This page does not have tracing turned on.Warn ("Double It". 11.Warn("Shipping". are shown. you can run the whole demonstration at the end of the lesson. "price = " + Convert. "price = " & CStr(TextBox1. 7. "shipping cost = " & CStr(shippingCost)) 4.Warn("Shipping". open the CallClassCS or CallClassVB Web site in the Democode\CS or DemoCode\VB folder. including the custom message you just added. 13. You can run this demonstration during the lesson while you discuss each of the previous topics.Tracing Through a Web Application Saturday.aspx code-behind page. Point out the custom trace messages and then close the browser window.Add the following trace statement to the Numbers. but the trace results are displayed anyway because application-level tracing is turned on. 9. "Value to double " + TextBox1. Trace information is shown on the page.Web element. 3.Demonstration . 5. turn tracing on in the Default. Enter a number into the box and then click Double It.NET Web Applications página 108 .config to turn off pageOutput. In Microsoft Visual Studio® 2008.Text)) Trace. Add two custom trace messages to the end of the click event procedure for Button2 in the Default. The following code illustrates this. The following code illustrates this. "Value to double " & TextBox1. Refresh the view of the Default.Text) 12. View the Numbers. and then view the page again. The trace results. 2008 12:21 AM You can run this demonstration by using either Microsoft C#® or Microsoft Visual Basic®. Close the browser window. Alternatively. Build and browse the Default. Trace.config file in the System. [Visual Basic] Trace. Set the pageOutput attribute to true.Text)). In the project. 14. 8.aspx page in the browser again. 10. Disable tracing for the page.aspx page.ToString(TextBox1.

web> <trace enabled="true" pageOutput="false"/> </system.x\Config\ In the web.config file. You can disable the trace viewer for a Web server by editing the web. in conjunction with the other configuration files in the folder.Student Book Content Displaying Trace Messages You can display application-level trace messages in two places: on the page itself or in the trace viewer. <configuration> <system.config file.axd (the trace viewer) is in the httpHandlers section. the trace messages are stored in memory. you set the pageOutput attribute of the trace element in the web.web> </configuration> If page output is disabled for application-level tracing.config file contained in the machine configuration folder.axd For security reasons. you may want to disable the trace viewer. You can locate the machine configuration folder in the following directory: %systemroot%\Microsoft. You can then view the trace messages by using the trace viewer. the reference to trace. You use the trace viewer by viewing the trace.config file in this folder.Web.axd" type="System.Handlers. The following code shows an example of disabling output to the page.config files for all web applications on the machine.NET\Framework\v2. <httpHandlers> <add verb="*" path="trace. and a setting of false keeps the trace messages in memory.NET Web Applications página 109 . This web.TraceHandler"/> </httpHandlers> Module 05-Tracing in Microsoft ASP. A setting of true displays the results on the page. which is a Web page that is included with each Web application.axd page in a browser: http://servername/projectname/trace. is inherited by all web. To determine how trace results are displayed.

Question: Why may you want to trace into a component? CD Content Module 05-Tracing in Microsoft ASP. Trace messages in a component will appear in any trace-enabled page that calls the component if trace is not intentionally disabled in the component. which then enables you to generate trace messages for both the Web Form and the component. you can add trace statements to that component. September 06. 2008 12:21 AM Instructor Notes (PPT Text) Student Book Content Tracing into a Component Key Points If you have a component that is called from a Web Form.Tracing into a Component Saturday.NET Web Applications página 110 .

NET Web Applications página 111 . Use the table in the topic to explain and summarize tracing into a component. Student Book Content Lesson 2 Remote Debugging You use debugging to catch errors when you create a Web application. Emphasize the importance of context and the use of the HttpContext. For most debugging operations. This lesson describes how to perform remote debugging. Remote debugging enables you to debug a Web application that runs at a remote location.Current property. September 06. 2008 12:21 AM Instructor Notes (PPT Text) Explain that it may be necessary to add trace statements to a component because components are often called from Web Forms.Remote Debugging Saturday. you run the Visual Studio 2008 debugger on the computer that hosts the Web application. Module 05-Tracing in Microsoft ASP.

you can also configure the monitor to run as a Windows service by using the Visual Studio 2008 Remote Debugger Configuration Wizard. September 06. Remote debugging enables you to debug Web applications on numerous disparate servers from a single workstation. you must configure the environments on both the debugger host and the remote computer. Question: When may you want to use remote debugging with an ASP. the remote server must grant access to the user who performs the debugging. When you perform remote debugging.exe). You can either install the Remote Debugging Monitor on the remote computer or run the monitor remotely from a shared folder. you use the Remote Debugging Monitor (msvsmon. You must also consider security features.NET application? CD Content Remote debugging is the process of debugging Web applications that runs on a separate server. The Remote Debugging Monitor can run as a Microsoft Windows ®-based application or as a Windows service. You may want to use remote debugging if you cannot run your Web application locally or you want to test the application while it is deployed on a Web server. the Remote Debugging Monitor runs as a Microsoft Windows ®-based application.exe). for example.NET or another server environment. Remote Debugging Monitor When you perform remote debugging. you use the Remote Debugging Monitor (msvsmon. 2008 12:21 AM Instructor Notes (PPT Text) Student Book Content Remote Debugging Overview Key Points Remote debugging is the process of debugging Web applications that runs on a separate server. To debug in ASP. By default.NET Web Applications página 112 . Module 05-Tracing in Microsoft ASP. Before you start remote debugging.Remote Debugging Overview Saturday. which is a small application to which Visual Studio 2008 connects. You start this wizard from the Visual Studio Tools folder on the Start menu.

Enabling remote debugging on the remote server. 2008 12:21 AM Instructor Notes (PPT Text) Explain that the easiest option is to run the Remote Debugging Monitor from a file share. These include: Enabling debugging in the ASP. you must carry out several configuration steps.NET Web Applications página 113 . Configuring security for the remote debugging environment. Student Book Content Performing Remote Debugging Key Points Before you perform remote debugging. you must carry out several configuration steps. This process also has security implications because the student must be logged on as the same user on both machines. mention that if students want to run the remote debugger from a share the must perform a manual attach to the server process. September 06. CD Content Before you perform remote debugging. Module 05-Tracing in Microsoft ASP.Performing Remote Debugging Saturday.NET application. However.

Lab . Mention that the worker process for the remote application differs between environments. The process can be one of the following: W3SVC on Microsoft Windows Server® 2003. If you have time. demonstrate how to enable debugging in an ASP. You will create a Web site that enables employees to select and set up their chosen benefits. Student Book Content Lab: Tracing in Microsoft ASP.NET application by using the Start with Debugging menu option. In this lab. In this exercise.NET Web Applications Exercise 1: Implementing Trace Statements Scenario Coho Winery offers several benefits to its employees.NET Web Applications página 114 . Open the Benefits Web site.exe on the Visual Studio 2008 development server.NET Web Applications Saturday. aspnet_wp on Windows XP. The main tasks for this exercise are as follows: 1. and WebDeb. September 06.Tracing in Microsoft ASP. you will trace through the execution of the Benefits Web application. you will enable and disable tracing and add custom messages to the trace output. 2008 12:21 AM Instructor Notes (PPT Text) Describe the steps required to configure and perform remote debugging.WebServer. Module 05-Tracing in Microsoft ASP.

View the code for the Benefits class in the App_Code folder. students trace into a component Before the students begin the lab. Comment out the trace messages in the Page_Load event procedure. 5.aspx page. Close the browser window. click the link located at the bottom of the relevant lab exercise page.behind file for the life. 2008 12:21 AM Instructor Notes (PPT Text) In this lab. 12.Implementing Trace Statements Saturday. because trace is turned off in the page. 7. In Solution Explorer. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. expand App_Code. and then double-click Benefits. read the scenario associated with each exercise to the class. Save your changes. 11. Comment out the trace messages in the GetBenefitsList method.vb. Note: The lab exercise answer keys are provided on the Course Companion CD.NET Web Form Exercise 2 In this exercise.aspx page. you have enabled tracing in a component and disabled tracing. Only the trace messages from the component. Remind the students to complete the discussion questions after the last lab exercise. students will perform tracing in a Microsoft ASP. Student Book Content If trace information is displayed on the page. 8.Exercise 1 . Module 05-Tracing in Microsoft ASP. 6. students add trace statements to a Microsoft ASP. View the code. 9.NET Web application Exercise 1 In this exercise. To access the answer key. Comment out the trace message in the Page_Load event procedure. 10.NET Web Applications página 115 .cs or Benefits. which custom trace messages are displayed? Why? A. September 06.behind file for the Default. Results: After this exercise. View the code.

Exercise 2 - Tracing into a Component
Saturday, September 06, 2008 12:21 AM

Instructor Notes (PPT Text)

Students will use the existing Coho Winery Benefits Web site and will trace through the execution of the application

Student Book Content
Messages written to the Debug object will only be displayed when you run the Web application in the debugger. Messages written to the Trace object will be displayed to the Web page as long as trace is enabled. 2. What is the difference between page-level tracing and application-level tracing? When you turn on page-level tracing for one page, trace information will only be displayed for that page. When you enable application-level tracing, trace information will be displayed on all pages in the Web application. 3. How do you enable application-level tracing? Set the enabled attribute of the trace element to true in the Web.config file. <trace enabled="true"/> 4. Read the following scenarios and determine whether trace messages will be displayed. a. Tracing is turned on in page1.aspx, but off in web.config. You view page1.aspx. Trace statements are displayed. b. Tracing is turned off in page1.aspx, but on in web.config. You view page1.aspx. Trace statements are not displayed. c. Tracing is turned on in page1.aspx, but off in web.config. You view page2.aspx. Trace statements are not displayed. d. Tracing is turned on in page1.aspx, and on in web.config. You view page2.aspx. Trace statements are displayed. e. Tracing is turned off in page1.aspx, but on in component A. You view page1.aspx and click a button that calls component A. Trace statements from component A are displayed, but page Trace.write statements are not displayed.

Module 05-Tracing in Microsoft ASP.NET Web Applications página 116

Overview of User Input Validation
Saturday, September 06, 2008 12:23 AM

Instructor Notes (PPT Text)
Lesson Overview

Student Book Content
Lesson 1

Overview of User Input Validation
Input validation verifies that the user has correctly filled in input controls on a Web Form before a request is processed on the server. There are several different types of input validation controls available in ASP.NET. This lesson introduces input validation, explains client-side and server-side validation, and describes the function of the ASP.NET validation controls.

Module 06-Validating User Input página 117

What Is Input Validation
Saturday, September 06, 2008 12:23 AM

Instructor Notes (PPT Text)

Do not spend more than the allotted time on this information. Each topic will be reviewed in context in later topics in this module. Emphasize that input validation always runs on the server and runs on the client if the client browser supports validation. To illustrate this, if time permits, enable and disable client-side scripting in the demonstrations for this module. Another example of a malicious code attack is pasting XML directly into input controls, which can have an effect similar to a SQL injection attack. For example, it is possible to send an XML Updategram or XQuery string into a password box in an attempt to compromise a system. There are many security tips that you can provide here; for example, you can advise students that they must always perform a server-side check, only access data through stored procedures, and never dynamically construct SQL strings from user input.

Student Book Content

What Is Input Validation?
Key Points
Input validation is the process of verifying that a user's input on a Web Form matches the expected data value, range, or format. This validation reduces the wait time for error messages and the likelihood of incorrect returns or Web site crashes due to problems with user input. ASP.NET server-side validation controls protect Web Forms against spoofing and malicious code. Questions: 1. Why do ASP.NET validation controls protect against spoofing and malicious code attacks? 2. Can you think of any spoofing or malicious code examples?

Module 06-Validating User Input página 118

Client-Side and Server-Side Validation
Saturday, September 06, 2008 12:23 AM

Instructor Notes (PPT Text)

To avoid spoofing, the validation is always repeated on the server side.

Student Book Content

CD Content
Input validation is the process of verifying that a user's input on a Web Form matches the expected data value, range, or format. Input validation improves a user's experience with the Web site by reducing the wait time for error messages and the likelihood of incorrect returns or Web site crashes due to problems with the user's input. When combined with understandable and useful error messages, input validation controls can greatly improve the usability of a Web application; this improves the customer's perception of the Web site's overall quality. Input validation controls act to verify that the user has correctly filled in an input control, such as a TextBox control, before the request is processed on the server. The input validation controls on a Web Form act as data filters before the page or server logic is processed. In ASP.NET, input validation always runs on the server side; it can also run on the client side if the client browser supports validation. If the browser supports client-side validation, the input validation controls perform error checking on the client before posting the data to the server. Users receive immediate feedback on whether the data that they entered is valid. For security reasons, any input validation that is run on the client side is then repeated on the server side.

Verifying Control Values
Input validation works by comparing user input against a predetermined input format. These predetermined input formats can include the number of characters, the use of alphanumeric characters, the value range, a specific character string, or a mathematical formula. For example, a user input control that requests users to enter their telephone number can have an attached input validation control that verifies that users have entered only numbers in a telephone number format. Entering letters or too few numbers triggers the input validation control to display an error message and require users to re -enter the data.

Prevents Page Processing
User input that matches the predetermined format is processed by the Web Form. User input that does not match the predetermined format triggers an error message and stops the Web Form from processing. Further processing of the page is blocked until the user input is corrected to meet the expected format and the page has been resubmitted for processing.

Module 06-Validating User Input página 119

ASP.NET Validation Controls
Saturday, September 06, 2008 12:23 AM

Instructor Notes (PPT Text)

Do not spend more than the allotted time on this information. Each control will be reviewed in context in the next lesson. Note: In Microsoft® Visual Studio®, create a new Web site and point out the six validation controls in the Validation group in the Toolbox. Add a TextBox and Button control to the Default.aspx page in preparation for the demonstration.

Student Book Content

ASP.NET Validation Controls
Key Points
ASP.NET provides six validation controls that are grouped together in the Validation group in the Toolbox: CompareValidator. Compares an input control to another input control, a fixed value, a data type, or a file. CustomValidator. Allows you to write your own code to create the validation expression. RangeValidator. Verifies that the user input is between two values or the values of other input controls. RegularExpressionValidator. Verifies that the entry matches a pattern that has been defined by a regular expression.

Module 06-Validating User Input página 120

Validation Controls
Saturday, September 06, 2008 12:23 AM

Instructor Notes (PPT Text)
Lesson Overview

Student Book Content
Additional Reading: For more information about ASP.NET validation controls, see "Types of Validation for ASP.NET Server Controls" at http://go.microsoft.com/fwlink/?LinkId=110692.

Module 06-Validating User Input página 121

September 06. display the typical properties of validation controls. Then. Module 06-Validating User Input página 122 . use the highlighter tool to show the common validation control attributes.Adding Validation Controls to a Web Form Saturday.NET and Visual Studio 2008 enables you to easily validate user input by providing input validation controls that provide server-side and client-side code when you add them to your Web Form. you had to write the equivalent client-side validation for each expected browser in a different script. Alternative delivery: In Visual Studio. Student Book Content Lesson 2 Validation Controls Validating user input used to be a tedious and time-consuming process. you first had to write validation code for the server in one language. 2008 12:23 AM Instructor Notes (PPT Text) The main point is that validation controls share a common object model so they all have the same properties. if you were going to perform client-side validation. This lesson demonstrates how ASP. For each input control. On the slide.

Adjust the display property of the RequiredFieldValidator to demonstrate the behavior. 2008 12:23 AM Instructor Notes (PPT Text) Explain that it is important to position validation controls correctly to make it clear to the user which control contains the error. It is important to position input validation controls so that it is clear to the user which control has the incorrect input. Also. For example. The asterisk is shown here for simplicity. Question: What is the distinction between the ErrorMessage and Text properties? Module 06-Validating User Input página 123 . Explain that you can use different characters instead of an asterisk. show what Display="none " does for the control and the effect that it has on validation processing.NET validation controls contain ErrorMessage and Text properties that can display invalid input messages at the location of the validation control. Place a RegularExpressionValidator and then a RequiredFieldValidator on a form next to a text box. Explain the difference between the ErrorMessage and Text error message properties.Positioning Validation Controls on a Web Form Saturday. ASP. The Display property sets the spacing of error messages from multiple validation controls on a Web Form. Alternative delivery: In Visual Studio. show the static and dynamic display modes by implementing two validation controls and testing the page with either mode. Student Book Content Positioning Validation Controls on a Web Form Key Points Input validation controls can display an error message when an input violation has occurred. you can use a large red bullet or even an image (by nesting an tag in the text attibute). September 06.

a telephone field that must conform to a certain pattern and be checked against database. 2008 12:23 AM Instructor Notes (PPT Text) Discuss why multiple validation controls may be required for a single control on a Web Form (for example.Combining Validation Controls Saturday. Question: Why is it sometimes necessary to validate user input by using multiple validation controls? Module 06-Validating User Input página 124 . September 06. link several validation controls to a single text box and test. a text box may be required content and also may require a specific format). Explain that you can use the supplied default patterns as a template for validation expressions. You can associate multiple validation controls to a single input control so that you can check user input for more than one validation requirement. for example. Student Book Content Combining Validation Controls Key Points Sometimes a single validation function or control is not sufficient to verify that the user has correctly entered data into an input control. Alternative delivery: In Visual Studio.

September 06. Verifies that the value entered matches an expected range. Mention validation groups but explain that they will be covered in the next lesson. RequiredFieldValidator. Create the controls and validate input with the code provided on the Course Companion CD. Module 06-Validating User Input página 125 . CompareValidator. Any character is a valid response with this validation control. Student Book Content Input Validation Controls Key Points The simplest validation controls are the RequiredFieldValidator. Alternative delivery: In Visual Studio. 2008 12:23 AM Instructor Notes (PPT Text) Ensure that the students understand when they can use each type of control. CompareValidator. Point out that a check on the date format of a CompareValidator control is dependent on your regional settings. All of these validation controls validate against fixed values or a second input control. RangeValidator. and RangeValidator controls. Tests a user's input against a specific value or against a second input control. display and explain the key properties of the three validation controls.Input Validation Controls Saturday. Forces a user to provide input in an input control.

the expressions themselves are additional information.. display the preset regular expressions by clicking the ellipsis (. Visual Studio 2008 provides a set of preset regular expression patterns that include e-mail addresses and telephone numbers. You can use the RegularExpressionValidator control to verify simple and complex expressions.) button for the ValidationExpression property.. This topic focuses on the use of the RegularExpressionVa lidator control. You can build your own custom regular expressions by using the set of control characters. 2008 12:23 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on this information.RegularExpressionValidator Control Saturday. September 06. Alternative delivery: In Visual Studio. Student Book Content RegularExpressionValidator Control Key Points You can use the RegularExpressionValidator control to verify that a user's input matches a predefined pattern such as a telephone number or e-mail address. Question: What are some common regular expression characters? Module 06-Validating User Input página 126 .

you have to write the client -side code when you use the CustomValidator control. see "Introduction to Regular Expressions" in the online JScript reference. <asp:TextBox id="emailTextBox" runat="server" /> <asp:RegularExpressionValidator id="emailRegexValidator" runat="server" ControlToValidate="emailTextBox" ErrorMessage="Use the format username@organization.xxx" ValidationExpression="\w+@\w+\. 2008 12:23 AM Instructor Notes (PPT Text) Unlike the other validation controls.CustomValidator Control Saturday. A string of at least one character.com. A period. \w+ \. Example of a Simple Expression The following code example shows how you can use a RegularExpressionValidator control to check if a user has entered a valid e-mail address. An invalid e-mail address for this control is: someone. An at sign (@). September 06. or someone@.com. A valid e-mail address for this control is: someone@example. Characters Definition \w+ @ A string of at least one character. Student Book Content Note: For more information about control characters.\w+" Text="*"> </asp:RegularExpressionValidator> The following table describes the specific pattern that the RegularExpression control checks in the previous example. \w+ A string of at least one character. Module 06-Validating User Input página 127 .com.

arguments) { alert("I am running on the client! ").aspx. Also. [Visual Basic] Dim value As Integer = args. add the following Microsoft Jscript® code to the end of the file.Demonstration . 2008 12:23 AM In this demonstration. set the ClientValidationFunction property to MyClientValidation.IsValid = False End If Visual Studio 2008 automatically creates the server-side event procedure with the name CustomValidator1_ServerValidate. if time permits. 2. 2. You can perform this demonstration by using either Microsoft Visual C#® or Microsoft Visual Basic®. Create a Web site.Value If value mod 2 = 0 Then args. } else { Module 06-Validating User Input página 128 . In the Design view of Default. Open Visual Studio 2008. • Write the client-side code 1. select the CustomValidator control. if (value % 2 == 0) args. you can demonstrate the effect of disabling client script. set the following properties for the CustomValidator control: • Text: It's an odd number • ControlToValidate: TextBox1 • Write the server-side code • Double-click the CustomValidator control to open the server-side event procedure and add the following code. This procedure contains two parameters: source type object) and args (type ServerValidateEventArgs). In the Properties window. September 06. students will see how to use a CustomValidator control to check on the server and client side if a TextBox control contains an odd or even number. 3. In the Source view of Default.ToInt16(args. var value = arguments.IsValid = true. Instructor Notes (PPT Text) function MyClientValidation(source. [Visual C#] int value = Convert. In the Design view of Default. add the following controls: • TextBox • Button • CustomValidator 4. if (value % 2 == 0) { arguments. else args. • Add a CustomValidator control 1.Value.Value).aspx. In the Properties window.Implementing the CustomValidator Control Saturday.IsValid = false.aspx.IsValid = True Else args.IsValid = true. 3.

The name of the script to run on the client side. The CustomValidator includes two properties: ClientValidationFunction. You must write the validation scripts for the CustomValidator control. If EnableClientScript is set to True and the client browser supports client-side scripting.aspx page. 3. OnServerValidate. Ensure that the EnableClientScript property of the CustomValidator control is set to True.IsValid = false. Build the Web site and browse the Default. The name of the script to run on the server side. The CustomValidator control validates on the server side. formula. Module 06-Validating User Input página 129 .} else { arguments. the client-side script runs before the server-side code to avoid a server round trip for the page. } } • Test the result 1. Student Book Content CustomValidator Control Key Points You can use the CustomValidator control when you want to use your own customized validation logic to check the user's input against a variable. or second source. it can also validate on the client side if the browser supports validation. 2.

September 06. 2008 12:23 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Page Validation You can use the Page.NET Web Form are valid before processing is initiated.IsValid property and how to implement the ValidationSummary control.IsValid property and the ValidationSummary control to verify that all validation controls on an ASP. This lesson explains the Page. Module 06-Validating User Input página 130 .Page Validation Saturday.

Validation controls do not bypass your code if a user input error is detected so you must test the state of your controls and prevent code from running if an error is detected. September 06.IsValid Property Saturday.IsValid check? Module 06-Validating User Input página 131 .The Page. If any one validation control is not valid. Question: Where do you normally perform the Page.IsValid Property Key Points You can determine if all of the validation controls on a page are currently valid by checking the IsValid property of the page at run time. the IsValid property returns false. 2008 12:23 AM Instructor Notes (PPT Text) Lesson Overview Student Book Content The Page.

indicate that the Validate method now has an overload that accepts the name of a validation group and validates only the controls that belong to the specified group. with a header and a list of errors. 2008 12:23 AM Instructor Notes (PPT Text) Mention that ASP.0 introduced validation groups. Student Book Content Implementing the ValidationSummary Control Key Points The ValidationSummary control displays when the Page. September 06. The Text property of a ValidationSummary control is displayed at the location of the validation control and warns the user that the input is invalid. Each of the validation controls on the page is polled and the ErrorMessage messages are aggregated by the ValidationSummary control. If client scripting is enabled. Also.NET 2.Implementing the ValidationSummary Control Saturday. Question: What symbol is normally used for the Text property to locate errors? Module 06-Validating User Input página 132 . The ErrorMessage property is displayed in the ValidationSummary control and contains a description of the input error.IsValid property returns false. the ValidationSummary control can display a message box or a text area.

You will also add a summary validation control to summarize the invalid entries on the page. Module 06-Validating User Input página 133 . In this lab. you can demonstrate the use of an embedded tag or other character by using the lab solution. The Benefits Web application has a Web Form named life. repeat the earlier comments about the Validation control Text property that is displayed next to the input control and the Errormessage property that is displayed in the ValidationSummary control. If time permits. Explain that you can use the * symbol is for simplicity or other characters of your choice. September 06. In the labs for this course.aspx. Alternative delivery: In Visual Studio. you will add validation controls to validate the entries in these text boxes.Lab . This page is used for the life insurance benefit and asks for a name. and a coverage amount from the user. a birth date. Student Book Content Lab: Validating User Input Exercise 1: Implementing RequiredFieldValidator Controls Scenario Coho Winery offers several benefits to its employees. you will create a Web site that enables employees to select and set up their chosen benefits.Validating User Input Saturday. display and explain the key properties of this validation control. 2008 12:23 AM Instructor Notes (PPT Text) To reinforce content.

students implement the CompareValidator control. 5.aspx Web Form. Exercise 2 In this exercise. To access the answer key. Birth Date. read the scenario associated with each exercise to the class. Red asterisks appear next to each box because a blank entry is invalid. Exercise 3 In this exercise. Note: The lab exercise answer keys are provided on the Course Companion CD. and Coverage boxes blank. September 06. students implement the RegularExpressionValidator control. 8. enter values for the Name. students will validate user input by using validation controls. Exercise 4 In this exercise.Exercise 1 .aspx in a browser. Before the students begin the lab. and Coverage boxes on the life. Remind the students to complete the discussion questions after the last lab exercise. and then click Save. In the browser. 2008 12:23 AM Instructor Notes (PPT Text) In this lab. View life. Your page should resemble the following illustration. Student Book Content When you change the Text property of the controls. students implement the RequiredFieldValidator control. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. you will change the text that appears in Design view. The red asterisks disappear because there is input in the boxes. 6.Implementing RequiredFieldValidator Controls Saturday. and Coverage boxes. 4. Module 06-Validating User Input página 134 . students implement the ValidationSummary control. leave the Name. Close Microsoft Internet Explorer ®. Birth Date. and then click Save. click the link located at the bottom of the relevant lab exercise page. 7. Birth Date. Exercise 1 In this exercise. Results:After this exercise. In the browser. Save all files. you have added RequiredFieldValidator controls for the Name.

In the Properties window. September 06.aspx.Exercise 2 . Task 1: Add a ValidationSummary control to the life. 2008 12:23 AM Instructor Notes (PPT Text) The Benefits Web application has a Web Form named life. Use the Toolbox to add a ValidationSummary control to the last cell of the second column of the table in the life. This page is used for the life insurance benefit and asks for a name.aspx page. 2. In this lab. students will add validation controls to validate the entries in these text boxes. Add a ValidationSummary control to the life. and a coverage amount from the user.aspx page 1.aspx Web Form. set the following properties for the control: ID: textBoxValidationSummary HeaderText: These errors were found: Your page should resemble the following illustration.aspx page. Test if the page is valid.Implementing the ValidationSummary Control Saturday. 2. you will use a ValidationSummary control to summarize the validation errors for the life. a birth date. Student Book Content Exercise 2: Implementing the ValidationSummary Control Scenario In this exercise. Students will also add a summary validation control to summarize the invalid entries on the page. Module 06-Validating User Input página 135 . The main tasks for this exercise are as follows: 1.

aspx Web Form. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. 4. Type: Specifies the data type to validate.Implementing the CompareValidator Control Saturday. Use the Toolbox to add a CompareValidator control to the life. Operator: Specifies the comparison operator to use for validation. 2. Property Value ID ErrorMessage Text birthCompareValidator Birth date format is invalid * ControlToValidate birthTextBox Operator Type DataTypeCheck Date Your page should resemble the following illustration. What are the properties that you should set for a RegularExpressionValidator control? Same as the RequiredFieldValidator control. 2008 12:23 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. Open the life. The main task for this exercise is as follows: Add a CompareValidator control. What are the properties that you should set for a RequiredFieldValidator control? ErrorMessage: Displays text in the ValidationSummary control Text: Displays validation message for the input control ControlToValidate: The control to validate 2. What are the properties that you should set for a CompareValidator control? Same as the RequiredFieldValidator control. 3. but you must also set Operator and Type properties. 3.Exercise 3 . September 06. next to the birthValidator control. you will use a CompareValidator control to validate the user entry into the Birth Date box. What are the properties that you should set for a ValidationSummary control? HeaderText: Displays introduction to the validation summary. Student Book Content Exercise 3: Implementing the CompareValidator Control Scenario In this exercise. Task 1: Add a CompareValidator control 1. 1. Set the following properties for the CompareValidator control. Module 06-Validating User Input página 136 . but you must also set the ValidationExpression property.aspx page in Design view. ValidationExpression: Specifies the regular expression for validation.

You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students. including: Creating a buffer overrun and crashing the server by entering a name with several thousand characters. Best Practices Help the students understand the best practices presented in this section. Task 1: Add a RegularExpressionValidator control Module 06-Validating User Input página 137 . Ask students to consider these best practices in the context of their own business situations. 2008 12:23 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. You can create high-level hints for each scenario by using the following possible solutions for the scenarios. This lack of validation can cause a number of problems.Implementing the RegularExpressionValidator Control Saturday. Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students. You must perform server-side validation to ensure spoofing is not an issue. Student Book Content Exercise 4: Implementing the RegularExpressionValidator Control Scenario In this exercise. September 06. • Users have added malicious text to a page on your Web site. you should provide some high-level hints that might help the students solve the problem stated in the scenarios. The main task for this exercise is as follows: Add a RegularExpressionValidator control. because users can turn off client-side script by changing browser options and not run the client-side validation code. which creates a false level of authorization. Validation is only susceptible to spoofing on the client side. addresses. Why can users add text to a page on your Web site and what problems can this cause? Users can add unlimited text to a Web page through user input controls that do not have input validation. Sending an SQL query to your customer database and downloading all of the data that is present. How can users make it appear that they have entered valid data or passed an authorization check? Users can modify the HTML page that is sent to them and then return values that make it appear that they have entered valid data or passed an authorization check. Creating and authenticating a new user account. including user names. you will use a RegularExpressionValidator control to validate the user entry in the Coverage box. • Your Web site is authorizing more users than are currently registered. Adding privileges to their own account and removing privileges from other accounts. If you assign the scenarios as homework. passwords. The page contains a registration form for new users.Exercise 4 . and credit card numbers.

Module 06-Validating User Input página 138 .\d{2})? Your page should resemble the following illustration. Property ID Value coverageRegexValidator ErrorMessage Text ControlToValidate Coverage must be a currency value * coverageTextBox ValidationExpression \d+(\. 2.1. Set the properties for the RegularExpressionValidator control as shown in the following table.aspx Web Form. Use the Toolbox to add a RegularExpressionValidator control to the life. next to the coverageValidator control.

NET page that other Web Forms can import as a server control. This lesson describes user controls and explains why they are a useful addition to your Web applications.Adding User Controls to an ASP. user controls provide UI and other related functionality. Similar to Web server controls.NET Web Form Saturday. After you create a user control.NET Web Form A user control is a Microsoft ® ASP. which are components that run on the server. It also describes how to reference a user control from an ASP. September 06.NET Web Form and how to access the properties in a user control. other Web pages in the same Web application can then use the control. 2008 12:24 AM Instructor Notes (PPT Text) Lesson overview Student Book Content Lesson 1 Adding User Controls to an ASP. Module 07-Creating and Implementing User Controls página 139 .

Web server controls are a special type of component that have a user interface. User controls have the following features: A user control resides in a Web Forms page. similar to a Web Forms page.ascx file extension from being viewed in a Web browser. 2008 12:24 AM Instructor Notes (PPT Text) Ensure that the students understand that user controls and Web server controls are not the same. However.NET Web applications. Web Forms user control. user controls must be included in a Web Forms page to work.NET Framework prevents files with the . user controls are typically compiled when first requested and then stored in server memory to reduce the response time for subsequent requests. Also.ascx file extension. user controls cannot be requested independently. It is possible to precompile user controls because they can be incorporated into the Web application Dll. Components provide logic only and are precompiled. avoid this discussion during the current module and revisit this issue in the deployment module (module 15). In addition. Similar to a Web Forms page. This security measure ensures that you cannot view the user control as a stand-alone ASP. and Web user control are three different terms that are used to refer to the same thing. Unlike Web Form pages. Note: The Microsoft . Student Book Content What Is a User Control? Key Points User controls enable you to reuse code and common UI components.NET page. you can author these controls by using any text editor or develop them by using code-behind classes. September 06.NET applications Definition User controls are ASP. You must therefore understand what they are and how they work before you can develop effective ASP.NET pages with an . inform the students that user control. however. A user control participates in the event life cycle for the Web Form. Students can easily confuse the two terms. Question: How can user controls be useful in your own applications? CD Content User controls can simplify the reuse of code and common UI components.What Is a User Control Saturday. A user control has its own page logic. User controls offer you an easy way to partition and reuse common UI functionality across your ASP. Module 07-Creating and Implementing User Controls página 140 .

2008 12:24 AM Instructor Notes (PPT Text) Establish the importance of user controls and explain that user controls are self-contained. None of the methods and properties of the user control conflict with the methods or properties of the hosting page. User controls can be used more than once in a hosting page without causing property and method conflicts. User controls can be written in a different language from the main hosting page. including the following: User controls are self-contained.Why Use User Controls Saturday. Mention that copying a user control to the root of multiple Web applications will have implications for source code control. and write them in a different language from the rest of the application. September 06. that students can reuse them across the pages of an application. CD Content Module 07-Creating and Implementing User Controls página 141 . Student Book Content Why Use User Controls? Key Points User controls have several advantages.

This lesson describes how to create and implement user controls. other pages in the same Web application can use it. September 06. Module 07-Creating and Implementing User Controls página 142 . 2008 12:24 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Creating User Controls After you create a user control.Creating User Controls Saturday.

ascx and modifying the markup in the source of the control. Student Book Content Creating a User Control Key Points You can create a user control by using either of the following two methods: Create a new user control by using the Add New Item dialog box in Visual Studio 2008. 2008 12:24 AM Instructor Notes (PPT Text) Inform the students that when they create a new user control. Convert an existing ASP.ascx file is created.Creating a User Control Saturday. If the students are not familiar with property procedures in Microsoft Visual C#®. clarify that the input parameter. Describe the methods that they can use to create a user control. value. an .NET page to a user control by changing the file extension of the page to . September 06. Question: What properties may be required for a user control that contains a check box? Module 07-Creating and Implementing User Controls página 143 . for the set part of the procedure is automatic.

This directive includes the following attributes: TagPrefix. Unique namespace for the user control to differentiate multiple user controls that have the same name. students can now display the graphical interface of the control in Design view from the hosting page. TagName. Instructor Notes (PPT Text) Student Book Content Adding a User Control to a Web Form Key Points The @ Register directive includes a user control in an ASP. 2008 12:24 AM Naming is an area that can create confusion for students. CD Content Module 07-Creating and Implementing User Controls página 144 . Virtual path to the user control file. Ensure that students are clear about the difference between the following attributes: • TagPrefix • TagName • Src Mention that in Microsoft Visual Studio® 2008.Adding a User Control to a Web Form Saturday. Unique name for the user control. September 06. Src.NET page.

students will see how to create and implement a user control by using Visual Studio 2008.ToString(value). 2. Create an event handler for the Text_Changed event of the text box in the user control. paste the text box and validation controls onto the user control.ascx. 8.Text = Value. which is accessible to the Set property. } set { number1TextBox.cs or numberBox. Visual Studio 2008 creates a template for the Get and Set properties.aspx page. The value that is passed is automatically placed into a variable called value. copy the code from the number1TextBox_TextChanged event handler to the number1TextBox_TextChanged event handler in the user control. 6. Name the user control numberBox. 9. The following code example illustrates this.Text) End Get Set(ByVal Value As Integer) number1TextBox.aspx code-behind file. In Visual Studio 2008. In Design view. The HTML uses the same combination of controls (a text box and two validation controls) in two places. } } [Visual Basic] Public Property pNum() As Integer Get Return CInt(number1TextBox. create a public property for the value of the text box. select and copy the first set of text box and validation controls on the Default. Module 07-Creating and Implementing User Controls página 145 .ToString() End Set End Property Point out that when you enter the header for the pNum property. 4.Text = Convert. 7.Text). Open the code-behind page for the new user control.ToInt32(number1TextBox.aspx page in the application. 2008 12:24 AM Instructor Notes (PPT Text) Use this demonstration to illustrate the previous topics as you cover them. To run this demonstration 1. Examine the HTML source of the Default.Creating and Implementing a User Control Saturday. Add a new Web User Control to the project. In the Default.ascx. [Visual C#] public int pNum { get { return Convert. Show the HTML for the page and point out the @ Control directive that was created by Visual Studio 2008.vb. In this demonstration. 10. Point out that the Set property does not take any arguments. open the UserControlCS or UserControlVB Web site in the Democode\Starter\CS or Democode\Starter\VB folder. In the code-behind page named numberBox.Demonstration . in the numberBox class. September 06. 3. In Design view.ascx. 5.

aspx page in Design view. 14.ascx user control onto the Web Form at the location of the first set of controls that you deleted.number1TextBox_TextChanged event handler in the user control. Delete the two sets of text boxes and validation controls (six controls in all). import the System. View the Default.Number). Student Book Content [Visual Basic] sumLabel. [Visual C#] num1.Number + num2.Drawing namespace. [Visual Basic] num1. 11. 15.Number = 7 Module 07-Creating and Implementing User Controls página 146 . Save your changes to the numberBox. In the code-behind file for the numberBox user control.ToString() The following example calls the Set property of the num1 and num2 user controls to display the constants 5 and 7 in the user control. 13. along with the tag for the user control. num2.Number = 7. View the HTML for the page.Text = (num1. In Solution Explorer.Number = 5 num2. drag the numberBox. the @ Register directive was added by Visual Studio 2008.ascx page. 16. 12.Number = 5.

View the Default. 27.aspx page in the browser again.Creating and Implementing User Controls Saturday. Close the browser window. Describe how the user controls are rendered in HTML and then close the browser window.Text = "0". 2008 12:24 AM Instructor Notes (PPT Text) 21. [Visual C#] if (!Page.aspx page of the Web site. 22. In this lab. The main tasks for this exercise are as follows: Module 07-Creating and Implementing User Controls página 147 . [Visual Basic] If Not Page. and then close the application. add initialization code to the Page_Load event procedure. you will create a user control from the Name and Birth Date controls on the life.Lab . Point out that the user control now has an initial value of 0.IsPostBack Then number1TextBox. Save your changes and then view the Default. View the HTML source in the browser.aspx Web Form in the browser. 23. In this exercise. Save and build the Web application. 25. September 06.aspx page.Text = "0" End If 26.IsPostBack) number1TextBox. you will create a user control to collect that information and then use this control on the medical.ascx user control. In the numberBox. 24. Student Book Content Lab: Creating and Implementing User Controls Exercise 1 Creating a User Control Scenario In many pages of the Coho Winery Benefits Web site. you collect the name and birth date from the user.

aspx page in Design view. 10. On the medical. 6. September 06. 8. students will create and implement a user control Exercise 1 In this exercise. 4. Note: The lab exercise answer keys are provided on the Course Companion CD. enter a name and birth date.EmpDOB. EventArgs e) { Label2. double-click Save to create a Click event procedure. Before the students begin the lab.Exercise 1 .aspx code-behind file. _ ByVal e As System. read the scenario associated with each exercise to the class. Student Book Content Write down the HTML that is created by Visual Studio 2008 for the user control.aspx page. click the link located at the bottom of the relevant lab exercise page.aspx page in the browser.Text = nameDate1.ToLongDateString() End Sub 7. View the medical.Text = nameDate1.ToLongDateString().EmpName + " born on " + nameDate1. [Visual C#] protected void saveButton_Click(object sender. 9. Verify that the name and birth date values appear in the Label control next to Save. and then click Save. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. 2008 12:24 AM Instructor Notes (PPT Text) In this lab.EmpDOB. Module 07-Creating and Implementing User Controls página 148 . Exercise 2 In this exercise. Remind the students to complete the discussion questions after the last lab exercise. Open the medical. write code to output the name and birth date values from the user control into the Label2 control on the medical.Creating a User Control Saturday. Close the browser window. students implement a user control.EventArgs) Handles saveButton. 5.EmpName & " born on " & _ nameDate1. students create a user control. In the Click event procedure. } [Visual Basic] Protected Sub saveButton_Click(ByVal sender As Object. Save the medical. To access the answer key.Click Label2. 11.aspx page Your code should resemble the following example. In the browser.

Module 07-Creating and Implementing User Controls página 149 .

aspx page of the Web site. Module 07-Creating and Implementing User Controls página 150 . In this lab. Student Book Content 5. students collect the name and birth date from the user. September 06.Exercise 2 .NET page? Why or why not? Yes.Implementing a User Control Saturday. 2008 12:24 AM Instructor Notes (PPT Text) In many pages of the Coho Winery Benefits Web site. Can you use two different user controls with the same name in the same ASP. You can use the TagPrefix and TagName attributes of the @ Register directive to distinguish each user control. students will create a user control to collect that information and then use this control on the medical.

NET provides for ASP.Overview of ADO. This lesson explains what ADO. September 06. Module 08-Accessing Data with Microsoft ADO.NET Saturday.NET Web Forms.NET Because of the importance of data storage in Web applications. you must have a thorough understanding of the data access methods that ADO.NET is and how it works. 2008 12:28 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Overview of ADO.NET and Visual Studio 2008 página 151 .

Each option will be reviewed in context in later topics in this lesson.NET more compatible and flexible than ADO? Module 08-Accessing Data with Microsoft ADO. 2008 12:28 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on this information. Contains numerous improvements over the previous version of ADO.NET Saturday.NET. You can easily connect your Web application to a database by using ADO.NET has the following attributes: Consists of a set of classes that you can use to connect to and manipulate data sources. do not emphasize the topic. you may have to explain what ADO is. Question: Why is ADO. September 06. however.NET and Visual Studio 2008 página 152 .What Is ADO.NET? Key Points ADO. Transfers data in XML format between the database and your Web application. Student Book Content What Is ADO. A brief history lesson may be required. Note: Depending on the knowledge of the students.

NET Object Model Key Points The ADO. There are two main components of the ADO.NET Data Provider. 2008 12:28 AM Instructor Notes (PPT Text) Mention that there are also data providers for ODBC and Oracle. regardless of the data source.NET and Visual Studio 2008 página 153 . Contains one or more DataTables and is designed for data access. Links the data source and DataSet.The ADO. .NET Object Model Saturday.NET object model provides an infrastructure that you can use to access data from different data sources. Student Book Content The ADO. Module 08-Accessing Data with Microsoft ADO. September 06.NET object model: DataSet.

September 06.NET and Visual Studio 2008 página 154 . DataReader objects are lightweight objects that you can use for read-only access to the data in a database. you typically use more DataReader objects than DataSet objects if you require a higher performance. 2008 12:28 AM Instructor Notes (PPT Text) The key point is that DataReader provides fast read-only access to data. DataSet objects consume a lot of resources.DataSets and DataReaders Saturday. Because most of the data on a Web page must only be read. Student Book Content DataSets and DataReaders Key Points DataSet objects are complex objects that enable you to store multiple DataTables of data from a data source. Question: When should you use a DataReader object instead of a DataSet object? Module 08-Accessing Data with Microsoft ADO.

The numbered items and matching arrows appear in sequence. Sending the data updates back to the database. Student Book Content Accessing Data with ADO. Manipulating the data. Module 08-Accessing Data with Microsoft ADO. 3. September 06.NET Key Points There are typically three stages in data access: 1. 2008 12:28 AM Instructor Notes (PPT Text) This is an animated slide.Accessing Data with ADO.NET and Visual Studio 2008 página 155 .NET Web Form. 2.NET Saturday. Accessing the data from a data source and displaying it on an ASP.

This lesson explains how to connect to different types of databases by using ADO.NET and Visual Studio 2008 página 156 . Module 08-Accessing Data with Microsoft ADO. 2008 12:28 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Connecting to a Database ADO. September 06.NET is used to connect a Web Form to a database.NET objects. It also explains how to store data in a DataSet.Connecting to a Database Saturday.

This server does not have to be the local computer and is typically changed to the production server after deployment (by storing connection strings in the Web. Student Book Content Generating a Connection by Using Server Explorer Key Points In the Visual Studio integrated development environment (IDE).Generating a Connection by Using Server Explorer Saturday.NET and Visual Studio 2008 página 157 . for example. Question: How can you change the data source type for a connection? Module 08-Accessing Data with Microsoft ADO.config file). 2008 12:28 AM Instructor Notes (PPT Text) Use a brief demonstration to illustrate how simple and quick it can be to create a connection to a database. Note: The server name indicates the named instance of SQL Express installed by default on the virtual computer. September 06. and preview data. investigate the properties of existing objects. You can also use Server Explorer to create database objects. you do not have to change Multiple Active Result Sets (MARS) settings. Server Explorer displays all connections in Data Connections. The use of SQLExpress for development is an excellent option if the application is eventually deployed to Microsoft® SQL Server® because typically only the server name must be adjusted. You can also add a connection to a database by using code. you can use Server Explorer to add a connection to a database. If you perform a demonstration. The Add Connections dialog box enables you to configure the connection. you can show the advanced options of the Add Connection dialog box.

September 06. untyped DataSets have no corresponding built-in schema. The DataAdapter object has four command-type properties that contain SQL statements or call stored procedures in the database. Explain that DataSet objects can be typed or untyped: • Typed. it uses several other objects to communicate with the database.xsd file) to generate a new class.NET and Visual Studio 2008 página 158 . similar to typed DataSet objects. • Untyped. untyped DataSet objects include tables and columns that are only exposed as collections. it uses a Connection object to connect to a database and Command objects to retrieve data and resolve changes to the database. 2008 12:28 AM Explain that the DataAdapter is used to populate a DataSet with data from an existing data source. Note: For the topic question. Module 08-Accessing Data with Microsoft ADO. Question: What are the four command-type properties? CD Content When a DataAdapter connects to a database. The information from the schema (such as tables and columns) is generated and compiled into this new DataSet class as a set of objects and properties. Typed DataSet objects are derived from the base DataSet class and use information in an XML schema file (an .The DataAdapter Object Model Saturday. However. Unlike typed DataSet objects. you can provide the following hint: "What SQL DML statements do you know about?" Instructor Notes (PPT Text) Student Book Content The DataAdapter Object Model Key Points When a DataAdapter connects to a database.

Add code to an event procedure of a control that uses a DataAdapter object. you typically add code to the Page_Load event procedure or to an event procedure of a control that uses a DataAdapter object. You can add a new DataSet object (XML schema file) to the App_Code folder and use it to programmatically create a DataSet object. Module 08-Accessing Data with Microsoft ADO. 2008 12:28 AM Instructor Notes (PPT Text) Briefly mention the points in this topic because the content is covered in more detail in the next lesson.NET and Visual Studio 2008 página 159 . Note: You may want to point out to the students that you can create a typed DataSet to represent the schema of a data store. perform one of the following: Add code to the Page_Load event procedure. Question: How can you fill a DataSet with data? CD Content To populate a DataSet.Generating a DataSet Saturday. September 06. Student Book Content Generating a DataSet Key Points To populate a DataSet.

Also point out that connection strings have many other parameters and they are typically dependent on the provider. You can pass these settings as parameters to the constructor of a connection object or save the connection string in the web. You can find a more comprehensive list in the documentation for the provider. you must identify the name of the database server. Database=MyDatabase. You can use a SqlConnection object to connect to SQL Server databases and the OleDbConnection objects to connect to all other databases. you can also use Server=localhost. Note: To create the connection string. Trusted_Connection=true.config file. Question: Which connection string parameter is the name of the database? Module 08-Accessing Data with Microsoft ADO.Creating a Connection Programmatically Saturday. September 06. Student Book Content Creating a Connection Programmatically Key Points To create a connection to a database. the name of the database. and the required login information.NET and Visual Studio 2008 página 160 . 2008 12:28 AM Instructor Notes (PPT Text) Emphasize that the Persist Security Info parameter is useful when you build an administration tool or debug an application.

Accessing Data Saturday. use DataSets for read and write access and use DataReaders for fast read-only access. For example.NET and Visual Studio 2008 página 161 . Explain that you can use a combination of both objects. Student Book Content Module 08-Accessing Data with Microsoft ADO. 2008 12:28 AM Instructor Notes (PPT Text) Briefly make comparisons between the DatSet and DataReader objects and typical usage scenarios. September 06.

When you add data in this manner. Autoformat. Module 08-Accessing Data with Microsoft ADO. September 06. Also. Visual Studio creates a GridViewcontrol and a SqlDataSource control and sets the properties of the controls accordingly.NET and Visual Studio 2008 página 162 . Student Book Content Binding Data to Controls by Using the IDE Key Points You can use Server Explorer to add data directly to a Web Form. explain that you can use Common GridView Tasks window to set most of the useful properties of a GridView control. and other common functionality. Question: How can you implement paging or sorting in a GridView control? CD Content The Visual Studio 2008 IDE enables you to create database connections. Note: Ask the topic question before you continue with the demonstration from the previous topic. automatically create a GridViewcontrol and a SqlDataSource object from a database table. 2008 12:28 AM Instructor Notes (PPT Text) Continue with the demonstration from the previous topic and show the students how to use Solution Explorer to add a control to a Web Form and bind the properties of the control to a data source. In the Properties window. and set properties of connections and data controls. set the properties of the GridView control to provide formatting.Binding Data to Controls by Using the IDE Saturday. editing. for example.

Creating a Command Object Saturday. 2008 12:28 AM Instructor Notes (PPT Text) Ensure that the students understand that each data provider has its own command object (such as SqlCommand or OleDbCommand).NET and Visual Studio 2008 página 163 . or execute a stored procedure. CD Content You can use a Command object to retrieve and modify data. OdbcCommand. and OracleCommand. Student Book Content Creating a Command Object Key Points You can use a Command object to retrieve and modify data. Explain that if a method returns a result as a boxed object. You can use the methods of a Command object to obtain a DataReader object. OleDbCommand. OdbcCommand. it is good programming practice to unbox or cast the value to the expected type. retrieve a single scalar value. and OracleCommand. September 06. A Command contains a database query and is represented by the provider-specific classes SqlCommand. A Command contains a database query and is represented by the provider-specific classes SqlCommand. The SqlCommand class provides four different methods to execute a command. OleDbCommand. Module 08-Accessing Data with Microsoft ADO. Explain the code required to use each of the command methods. Emphasize that the ExecuteScalar method returns an object.

you must write extra code to provide that functionality. you open the connection as late as possible and close it as soon as possible. you must create a SqlCommand object. Explain that for performance reasons. Question: Why must you always explicitly close the Connection object? Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 164 . You can create a Command object from a SQL statement and a connection.ExecuteReader. Therefore. you must manage the connection yourself. forward-only access to data.Creating a Data Reader Saturday. ADO. Student Book Content Creating a Data Reader Key Points To use a SqlDataReader object. if you want to perform connected operations. The SqlCommand object exposes an ExecuteReader method that returns a SqlDataReader object. but you must also explicitly open and close the Connection object. September 06. 2008 12:28 AM Instructor Notes (PPT Text) Remind the students that a DataReader provides read-only.NET is designed to operate in a disconnected way. Explain that the key steps are to create an instance of the Command object and then create a DataReader by calling Command. Because this is a connected operation.

Dim myDataReader As SqlDataReader myDataReader = authorsSqlCommand. myDataReader. " + _ myDataReader("FirstName")) Loop ' Close DataReader and connection. myDataReader = authorsSqlCommand. you must always use a Try"¦Catch"¦Finally statement to ensure that if anything fails. // Use the returned data in the DataReader.Add(myDataReader("LastName") + ".Close().Close(). However.Read() namesListBox. Student Book Content // Close DataReader and connection.Retrieving Data by Using a DataReader Saturday.integrated security=true. the DataReader provides a series of methods that you can use to access column values in their native data types (for example. the connection will close. The following code for a DataReader object catches errors and closes the connection." & _ "initial catalog=myDatabase") Dim authorsSqlCommand As New SqlCommand _ ("select * from Authors". } Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 165 . connection.ExecuteReader(). [Visual C#] try { connection.Close() connection.ExecuteReader() Do While myDataReader. the connection may be left open indefinitely. 2008 12:28 AM Instructor Notes (PPT Text) Explain that it is possible to access each column of a returned row by passing the name or ordinal reference of the column to the DataReader.Open(). September 06. Dim connection As New SqlConnection _ ("data source=localhost. for best performance. GetDateTime and GetDouble).Close() Error Handling with DataReader Objects When you use connections with the DataReader object.Items.Open() ' Create DataReader and display data. [Visual Basic] ' Open connection and create command. connection) connection. myDataReader. Otherwise.

NET and Visual Studio 2008 página 166 . } catch(Exception e) { // Handle the error.// Use the returned data in the DataReader. } finally { Module 08-Accessing Data with Microsoft ADO.

DataRelation. Student Book Content Creating a DataSet Key Points To create a local copy of a database.Creating a DataSet Saturday. Firstly. Note: To create a typed data set. Question: What does the SelectCommand property of the DataAdapter object contain? Module 08-Accessing Data with Microsoft ADO. exceptions can be thrown if the results returned from executing the select command do not conform to the schema. you can programmatically access the data. add an . you can create and populate a DataSet object by using DataTable objects. declare the DataSet object name. and Constraint in a DataSet and populate the tables with data. typically they will want to populate the DataSet with data from an existing data source and for this they can use a DataAdapter. 2008 12:28 AM Instructor Notes (PPT Text) Refer the students back to the DataAdapter object model in the second lesson. and then fill the DataTable objects by creating a DataAdapter object. After you have placed data in a DataSet object. September 06. explain that the second string parameter of the Fill method is the table name associated with the DataTable object in the DataSet. In the code examples. However. For a typed dataset.NET and Visual Studio 2008 página 167 .xsd file to the Web application and create an instance of the class. Explain that they can programmatically create a DataTable.

-ormyDataSet." & _ "integrated security=SSPI. [Visual C#] myDataSet. You use this name to access the returned data. myDataAdapter. [Visual Basic] ' Create a connection. each DataSet object consists of one or more DataTable objects that you can refer to by name or by ordinal position. Dim myDataAdapter As New SqlDataAdapter _ ("select * from Authors". // Create the DataAdapter.persist security info=True. Student Book Content // Create the DataSet. // Fill the DataSet myDataSet.Fill(myDataSet.Tables[0]. DataSet myDataSet = new DataSet(). SqlDataAdapter myDataAdapter = new SqlDataAdapter ("select * from Authors". [Visual Basic] Module 08-Accessing Data with Microsoft ADO.Displaying a DataSet in a List-Bound Control Saturday. Dim myDataSet As New DataSet() ' Create the DataAdapter.Fill(myDataSet. connection) ' Fill the DataSet myDataSet.NET and Visual Studio 2008 página 168 . Dim connection As New SqlConnection _ ("data source=localhost. Accessing a DataTable After you have placed data in a DataSet object. As the following code illustrates.Tables["Authors"]. "Authors") The second argument to the Fill method is a name for the DataTable object that is created. myDataAdapter.initial catalog=pubs. 2008 12:28 AM Instructor Notes (PPT Text) Use a simple demonstration to show students how to bind a DataSet to any list-bound control on a Web Form. you can programmatically access the data.") ' Create the DataSet. September 06. "Authors"). connection).

Tables(0) Module 08-Accessing Data with Microsoft ADO.Tables("Authors") -ormyDataSet.NET and Visual Studio 2008 página 169 .[Visual Basic] myDataSet.

September 06. To capture these messages.NET and Visual Studio 2008 página 170 . Student Book Content Module 08-Accessing Data with Microsoft ADO. To minimize the impact of this. it is always good practice to check for the connection state before you open or close the connection. developers must enumerate the errors collection to check for these specific class errors if necessary. the server closes the connection.Handling Exceptions Saturday. Explain that the severity levels 1-10 are informational or warning errors and do not invoke the client exception handler. 2008 12:28 AM Instructor Notes (PPT Text) Ensure that the students understand the importance of error handling when you attempt to access data. If an error with severity level 20-25 occurs. This may cause other parts of your code to break if it relies on this connection.

and each DataTable object can come from a different data source. It also explains how to display that data in GridView controls. 2008 12:28 AM Instructor Notes (PPT Text) Student Book Content Lesson 4 Accessing Multiple Tables One of the strengths of DataSet objects is that they can contain multiple DataTable objects.NET and Visual Studio 2008 página 171 .Accessing Multiple Tables Saturday. Module 08-Accessing Data with Microsoft ADO. September 06. This lesson explains how to store multiple tables of data in a DataSet object.

Question: How can you preserve referential integrity between related tables in a database? Module 08-Accessing Data with Microsoft ADO. You can control the order in which updates are written to and from the database because the order of the DataAdapter objects controls the order of implementation. September 06. you can use multiple DataAdapter objects.Storing Data From Multiple Tables Saturday. Student Book Content Storing Data From Multiple Tables Key Points To fill a DataSet object with multiple DataTable objects that come from one or more data sources. You must use a new DataAdapter object for each DataTable object in a DataSet object. 2008 12:28 AM Instructor Notes (PPT Text) A best practice for storing multiple tables is to use one DataAdapter for each table in the DataSet.NET and Visual Studio 2008 página 172 .

OrderDate. OrderDate. [Visual Basic] ' Create the second DataTable.Fill(myDataSet. pubsConnection) ordersDataAdapter. "Customers") Adding Subsequent Tables After the first DataTable object is loaded. You must define the relationships to enforce referential integrity.NET and Visual Studio 2008 página 173 . Student Book Content 'Create the first DataTable. "Orders") Note: You must use a new DataAdapter object for each DataTable object in a DataSet object. ordersDataAdapter = new SqlDataAdapter ("select CustomerID. OrderID. customersDataAdapter = New SqlDataAdapter _ ("select CustomerID. Module 08-Accessing Data with Microsoft ADO. "Orders").Fill(myDataSet. particularly if you want to submit changes back to a data store. ShippedDate " + "from Orders". CompanyName from Customers". pubsConnection). _ pubsConnection) customersDataAdapter. The following code continues from the preceding example and populates the Orders DataTable object by using a DataAdapter object named ordersDataAdapter. OrderID.Creating Relationships Saturday. 2008 12:28 AM Instructor Notes (PPT Text) Explain that a DataRelation enables navigation from one DataTable to another in a DataSet. you can fill additional DataTable objects and define the relationships between the objects based on the initial DataTable object. ordersDataAdapter = New SqlDataAdapter _ ("select CustomerID. ShippedDate " & _ "from Orders".Fill(myDataSet. ordersDataAdapter. September 06. [Visual C#] // Create the second DataTable.

com/fwlink/?LinkId=111442. For more information about the CreateChildView method. you can use the DataSet object.CreateChildView Method (DataRelation)" at http://go. Student Book Content Programmatically Navigating Between Tables by Using Relationships Key Points When you want to work with data from related tables.Programmatically Navigating Between Tables by Using Relationships Saturday. 2008 12:28 AM Instructor Notes (PPT Text) Briefly explain the code required to navigate between tables by using a DataRelation. September 06.microsoft. The DataSet object enables you to work with multiple DataTable objects and define a relationship between them. Note: You can use the CreateChildView method to visually navigate from one DataTable object to another DataTable object in a DataSet object.NET and Visual Studio 2008 página 174 . You can use the relationship to navigate between related records in the tables. Question: What functionality do the GetChildRows and GetParentRowmethods of a DataRowobject provide? Module 08-Accessing Data with Microsoft ADO. see "DataRowView.

Module 08-Accessing Data with Microsoft ADO. Exercise 2 In this exercise. students retrieve data from a SQL Server database by using a SqlDataReade r. At this stage. it is not best practice to request the data every time you view the data.NET development.Lab .NET and Visual Studio 2008 página 175 .NET and Visual Studio 2008 Saturday. students implement paging and selection in a GridView control. In the labs for this course. students display data from a SQL Server database on a Web Form. Before the students begin the lab. To access the answer key. students will access data with Microsoft ADO. students are becoming aware that they must consider performance for many facets of ASP. Student Book Content Lab: Accessing Data with Microsoft ADO. students implement an All option and reset functionality in a Web page. Exercise 4 In this exercise. Note: The lab exercise answer keys are provided on the Course Companion CD. September 06. read the scenario associated with each exercise to the class.NET and Microsoft Visual Studio® 2008. Remind the students to complete the discussion questions after the last lab exercise. 2008 12:28 AM Instructor Notes (PPT Text) In this lab. Explain that if you view static data in the GridView control. click the link located at the bottom of the relevant lab exercise page. Emphasize this point so that students think about optimizing their data access code. a database request is sent every time that the user selects a new item in the list. Exercise 3 In this exercise.Accessing Data with Microsoft ADO. you will create a Web site that enables employees to select and set up their chosen benefits. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. Note: In Exercise 3.NET and Visual Studio 2008 Exercise 1: Connecting to the Doctors Database Scenario Coho Winery offers several benefits to its employees. Exercise 1 In this exercise.

students will create a page to display all of the doctors in the database and enable a user to select one of the doctors as their primary care physician.Exercise 1 . 2008 12:28 AM Instructor Notes (PPT Text) One benefit that is offered by Coho Winery is medical insurance.aspx page to enable users to list doctors that are in specific cities. Module 08-Accessing Data with Microsoft ADO. When users apply for medical insurance.NET and Visual Studio 2008 página 176 . The doctors' addresses are also in the database. you have implemented paging for the DataGrid control on the doctors. September 06. they must select a primary care physician.Connecting to the Doctors Database Saturday.aspx page and enabled the user to select a doctor from the DataGrid. In this lab. Students will enhance the doctors. Student Book Content Results:After this exercise. The doctors that are approved by Coho Winery are all listed in a SQL Server database.

How do you create a relationship between two DataTable objects in a DataSet object? Create a new DataRelation object from the two related DataColumns of the DataTable objects. 5." + "integrated security=true. After the connection to the database is closed. 2008 12:28 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises.initial catalog=coho") 4. How can you add a connection to a database? In Server Explorer. and then click Add Connection. forward-only stream that is returned from the database. [Visual Basic] connection = New SqlConnection("data source=localhost. configure the connection.Exercise 2 . and data. relationships. 3. constraints. In the Add Connection dialog box. What control is created when you drag a table from Server Explorer to a Web page? Visual Studio creates a GridView object and a SqlDataSource object and sets the properties of the objects. set the AllowPaging property to True. the DataSet continues to exist. what must you do? To minimize the impact on system resources. How can you enable paging for a GridView control? When the control is selected.Paging and Selection in a GridView Control Saturday. The DataReader class is designed to produce a read-only. When you use Connection and SqlDataReader objects. What is the difference between a DataSet and a DataReader object? The DataSet object is designed to handle the actual data from a data store. The DataSet class represents a cache of data and has database-like behavior. Module 08-Accessing Data with Microsoft ADO. on the local computer running SQL Server. How can you add a select column to a GridView control? In the Columns property of the control. 5. call the Close method on the objects when they are no longer required. by using integrated security? [Visual C#] connection = new SqlConnection("data source=localhost. 1. columns. and then click OK. What code creates a connection to a database named Coho. 2. September 06. 4." & _ "integrated security=true. right-click the Data Connections folder. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. Student Book Content Dim myDataSet As New DataSet() 3.NET and Visual Studio 2008 página 177 . The DataReader is destroyed when the connection to the database is closed. The DataSet object contains tables. in the Properties window. add a Select CommandField. initial catalog=coho"). and then add the DataRelation object to the Relations collection of the DataSet object.

You can create high-level hints for each scenario by using the following possible solutions for the scenarios. There is also more overhead when you create a DataSet object • You intend to both read from and write to your data source. Why must you use a DataSet object instead of a DataReader object? If you intend to both read from and write to your data source. Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students. If you assign the scenarios as homework. Student Book Content Module 08-Accessing Data with Microsoft ADO. Why must you use a DataReader object instead of a DataSet object? DataSet objects access data from a database more slowly than DataReader objects because DataSet objects store the data in an object on the Web server. you should provide some high-level hints that might help the students solve the problem stated in the scenarios. Can you use a DataSet object or a DataReader object? You can only use a DataSet object. DataReader objects are read-only connections and you must use them only when the data will be used in a read-only situation. 2008 12:28 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students. DataReader objects are based on a single or multiple SQL statements from a single database.Implementing a SqlDataReader Saturday. • You want to combine tables from three databases.Exercise 3 . • You require high-speed access to your data source. September 06. Best Practices Help the students understand the best practices presented in this section. you must use a DataSet object. Ask students to consider these best practices in the context of their own business situations.NET and Visual Studio 2008 página 178 .

(If Time Permits) Viewing Doctors from All Cities Saturday.Exercise 4 .NET and Visual Studio 2008 página 179 . 2008 12:28 AM Student Book Content Module 08-Accessing Data with Microsoft ADO. September 06.

these include efficiency. September 06. Stored procedures have several advantages over direct database access. and the protection of the database. This lesson describes stored procedures and explains the reasons why you call stored procedures when you access a database. security. 2008 12:30 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Overview of Stored Procedures One alternative to direct database access from your Web application is to call a stored procedure that accesses the database for you.Overview of Stored Procedures Saturday. Module 09-Accomplishing Complex Data Access Tasks página 180 .

and recipient of the last three checks that were processed in a bank account. Question: What stored procedures do you use in your own applications? CD Content A stored procedure is a database procedure that a database developer writes for use with a specific database. you often use return value stored procedures in code and then display the result to users. sort and filter those records. You may be able to skim this first lesson. Programmatic Access to a Database Stored procedures enable you to call an existing procedure to access a database. You use return value stored procedures to run a database command or function that returns a single value.What Is a Stored Procedure Saturday. Stored procedures that you create in a SQL Server database consist of one or more sequences of Transact-SQL statements and can have input and output parameters. 2008 12:30 AM Instructor Notes (PPT Text) Check to see how familiar your students are with stored procedures. date. and the stored procedures can have both input and output parameters. The three types of stored procedures are: Return records stored procedures. Student Book Content What Is a Stored Procedure? Key Points You create stored procedures for use with a specific database and store them in that database. September 06. also known as scalar stored procedures. An example of a return records stored procedure is a request for the amount. You can load this data into a DataSet object for further processing or display it directly to the user in a ListBox control. and then return the result to a data set or to a list-bound control. Module 09-Accomplishing Complex Data Access Tasks página 181 . You use return records stored procedures to find specific records. Other Web applications can then call these stored procedures to access and manipulate data in the database. rather than writing your own SQL statements. Stored procedures function similarly to procedures in a Web application in that your code calls them by name. Because only one value is returned. You build stored procedures in a SQL Server database from sequences of Transact-SQL statements. These stored procedures are based on SQL Select statements. Return value stored procedures.

flexibility. they can provide increased security. Question: How can stored procedures improve the security or performance of your own applications? CD Content Module 09-Accomplishing Complex Data Access Tasks página 182 .Why Use Stored Procedures Saturday. and a reduction in network traffic. 2008 12:30 AM Instructor Notes (PPT Text) Discuss the advantages of stored procedures over manual queries. faster performance. September 06. Student Book Content Why Use Stored Procedures? Key Points Stored procedures have several advantages over direct Transact -SQL statements. For example.

and handle output parameters. pass any input parameters that are required to process your request. pass input parameters. This lesson describes how to call stored procedures. Module 09-Accomplishing Complex Data Access Tasks página 183 . and handle the output parameters that are included in the response. you can call the procedure. 2008 12:30 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Calling Stored Procedures Before you can call a stored procedure. After you identify the stored procedure. you must identify the procedure name and the available parameters. September 06.Calling Stored Procedures Saturday.

modify and debug stored procedures. as shown in the following list: Return records stored procedures. Module 09-Accomplishing Complex Data Access Tasks página 184 . as shown in the following list: Return records stored procedures. When you call a stored procedure that returns a set of records. in particular. show the students how to read the output data types and names of stored procedures. When you call a stored procedure that returns a single value. September 06. Return value stored procedures. you must identify its type and then choose the method that you want to use to call the stored procedure. Call the ExecuteScalar method of the Command object and save the result in a variable of the appropriate data type. the first step is to identify the type and name of the stored procedure. CD Content To call a stored procedure. You can briefly show this in the demonstration. you use a DataAdapter and the Fill method. Identifying the Stored Procedure When you call a stored procedure. You can use a DataAdapter object or a DataReader object to call all three types of stored procedures. The method that you call to run the stored procedure varies depending on the type of stored procedure that you want to call. (Also mention that stored procedures must not start with sp_. Perform action stored procedures. and save the result in a variable of the appropriate data type. call the ExecuteScalar method of the Command object. you use a Command object and the ExecuteReader method and then bind the returned record into a list-bound control. you can store that set of records in a DataSet or use a DataReader to place the records directly into a list-bound control. Return value stored procedures. 2008 12:30 AM Instructor Notes (PPT Text) Mention that the lesson starts with simple stored procedures and then explains more complex stored procedures with parameters.Calling Stored Procedures Saturday. If you want to use a DataSet.) Student Book Content Calling Stored Procedures Key Points The method that you call to run the stored procedure varies depending on the type of stored procedure that you want to call. Explain that you can identify the stored procedure type in Microsoft® Visual Studio® 2008 by using Server Explorer and also create. If you want to use a DataReader. Call the Fill method of the DataAdapter to place the records in a DataSet or call the ExecuteReader method of the Command object to place the records in a DataReader. Call the ExecuteNonQuerymethod of the Command object.

the order of the parameters is flexible. however. September 06. Question: What is the difference between an output parameter and a return value parameter? CD Content Module 09-Accomplishing Complex Data Access Tasks página 185 .Parameters in Stored Procedures Saturday. 2008 12:30 AM Instructor Notes (PPT Text) Ensure that the students are familiar with the concept of parameters and specifically with the difference between output parameters and the return value of a stored procedure. Emphasize that the Direction property of a ReturnValue parameter must be set to ParameterDirection. ReturnVa lue. Student Book Content Parameters in Stored Procedures Key Points Parameters enable you to pass information into a stored procedure and receive information back from it. The names of the parameters that you add to the Parameters collection of the SqlCommand object must match the names of the parameters that are in the stored procedure.

Module 09-Accomplishing Complex Data Access Tasks página 186 . Student Book Content Passing Input Parameters Key Points To create an input parameter.Passing Input Parameters Saturday. or return value parameters. Set the Direction property of the new parameter. September 06. you must then add the parameters that you require to the Parameters collection of the Command object. use the following steps: Create a new SqlParameter object with the name and data type of the parameter. 2008 12:30 AM Instructor Notes (PPT Text) Step through the code required to create a parameter and add it to the Parameters collection. CD Content After you identify the parameters that a stored procedure supports. Explain to the students that they can use the workParam1 variable shown in the code example to create additional parameters. these include input. Use the Add method of the Parameters collection to save the new parameter. output.

you access the value of the output parameter in the Parameters collection after the stored procedure has run. you access the value of the output parameter in the Parameters collection after the stored procedure has run. Example of Output Parameters Module 09-Accomplishing Complex Data Access Tasks página 187 . CD Content To read the value of an output parameter or to read a returned value from a return records stored procedure. Student Book Content Accessing Output Parameters Key Points To read the value of an output parameter or to read a returned value from a return records stored procedure. September 06. 2008 12:30 AM Instructor Notes (PPT Text) Step through the code required to read the value of an output parameter.Accessing Output Parameters Saturday.

aspx page in the browser. Creates the input parameter.aspx page. 13. In this demonstration. 11. 14. b. point out the code that does the following: a. point out the code that does the following: a. 7. 9. 12. Adds the input parameter and set its properties. view the code -behind page for the default. Module 09-Accomplishing Complex Data Access Tasks página 188 . 5. Creates the Command object.In the available list. you will see how to call a stored procedure that has two input parameters and then bind the results to a GridView control. b.In Visual Studio 2008. select a specialty. select a specialty. Creates the SqlConnection. 6.Passing Parameters Saturday. To run the demonstration 1.Click Get Data. Ensure that you include code to close the reader first before you access the return value. 2008 12:30 AM Instructor Notes (PPT Text) You can use the demonstration to illustrate the topics in this lesson as you discuss them. 4.In the getDataButton_Clic k event procedure. Creates the SqlDataAdapter and sets properties of the SelectCommand object to call the DentistsBySpecialty stored procedure. Comment out the code underneath the "Call a stored procedure by using a DataAdapter"• comment. view the code -behind page for the default.aspx page. Creates a new DataSet and fills the DataSet from the DataAdapter. Uncomment the code underneath the "Call a stored procedure by using ExecuteReader"• comment.Demonstration . View the default. d. In the getDataButton_Clic k event procedure. and construct the appropriate code to read this value and display it in a label control on the page.View the default. c. Executes the DataReader. September 06. In the Democode\CS or Democode\VB folder. c. 2. Student Book Content Demonstration: Passing Parameters In this demonstration. extend the demonstration to show how to read a return value from a stored procedure. A GridView control is bound to the DentistsBySpecialty stored procedure in the Dentists database. 3. Add a Return @@rowcount statement to the stored procedure in the database. students will see how to call a stored procedure with one input parameter and then bind the results to a GridView control. In Visual Studio 2008. In the available list.aspx page in the browser. 10. Click Get Data. If you have time. open the Parameters Web site. 8.

which provides a way for you to query data by using Microsoft Visual C# ® or Microsoft Visual Basic ®.NET Framework 3. September 06. 2008 12:30 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Data Access by Using LINQ to SQL Microsoft Visual Studio ® 2008 and the .Data Access by Using LINQ to SQL Saturday. This lesson introduces LINQ and describes how to use Visual Studio 2008 to query a SQL Server database by using LINQ to SQL.5 introduce Language-Integrated Query (LINQ). Module 09-Accomplishing Complex Data Access Tasks página 189 .

LINQ to Objects. LINQ Implementations Visual Studio 2008 includes LINQ provider assemblies that enable you to use LINQ with several different types of data. LINQ provides a programming model that you can use to retrieve and update data from a variety of sources by using Visual C# and Visual Basic syntax. This capability gives you a simplified method to write queries because you can make use of your current Visual C# or Visual Basic knowledge.5 introduce Language-Integrated Query (LINQ). A LINQ technology that enables you to query in-memory data such as arrays and lists.NET Framework 3. and XML.What Is LINQ Saturday.5. Module 09-Accomplishing Complex Data Access Tasks página 190 . September 06. including the following: LINQ to DataSet. A LINQ technology that enables you to query data cached in a DataSet object. Explain that this version of the Framework includes libraries that provide LINQ support for data stores that include DataSets. Visual Studio 2008 provides designer tools that you use to create an object-relational mapping to the objects in the data store that you want to query. objects. LINQ to SQL.NET Framework 3. Question: What are the advantages of a model that enables you to use Visual C# or Visual Basic to query a database? CD Content Visual Studio 2008 and the . Visual Studio 2008 provides designer tools that you use to create an object-relational mapping to the objects in the data store that you want to query. A LINQ technology that enables you to query data in relational databases. 2008 12:30 AM Instructor Notes (PPT Text) Mention that Language-Integrated Query (LINQ) is a part of the . relational databases. Student Book Content What Is LINQ? Key Points Language-Integrated Query (LINQ) provides a programming model that you can use to retrieve and update data from a variety of sources by using Visual C# and Visual Basic syntax. You can also use the Microsoft IntelliSense ® and debugging support of Visual Studio 2008 to catch and resolve errors at compile time. LINQ also provides a unified syntax that you can use to query any data source that supports LINQ.

Use a simple demonstration to illustrate the topics of this lesson as you discuss them. Student Book Content Creating a LINQ to SQL Object Model Key Points You define the object model for a database in a LINQ to SQL Classes file. To open the Object Relational Designer (O/R Designer). 2008 12:30 AM Instructor Notes (PPT Text) Mention that the Object Relational Designer (O/R Designer) supports SQL 2000. September 06.dbml extension. you add a LINQ to SQL Classes file to your application by using the Add New Item dialog box. CD Content Module 09-Accomplishing Complex Data Access Tasks página 191 . Explain that students can open the O/R Designer by adding a new LINQ to SQL Classes item to a project. which has a .Creating a LINQ to SQL Object Model Saturday. SQL 2005. and SQL Express.

Question: What is the purpose of the DataContext class? CD Content Module 09-Accomplishing Complex Data Access Tasks página 192 . If students are interested. 2008 12:30 AM Instructor Notes (PPT Text) Explain to the students that they can use DataContext methods to run stored procedures and functions in a database. Visual Studio 2008 creates a DataContext class. In addition. show the designer-generated entity classes in the Class View window. September 06. This class contains properties that represent each table that you add to the O/R Designer and methods that represent each stored procedure or function.The DataContext Class Saturday. Student Book Content The DataContext Class Key Points Visual Studio 2008 creates an entity class for each database table in the O/R Designer. Mention that it is also possible to add new methods to the DataContext class.

2008 12:30 AM Instructor Notes (PPT Text) Explain that after you create the object model. A query expression must always begin with a fromclause and end with either a select or a group clause. and orderby. where. Student Book Content Querying a Database Key Points After you model a database by using the O/R Designer. the next step is to write code that uses the model to run queries against the database. CD Content After you model a database by using the O/R Designer. let. Other optional clauses include join. you can manipulate data through the model by using the objects and properties that the model contains. September 06. Module 09-Accomplishing Complex Data Access Tasks página 193 .Querying a Database Saturday. the next step is to write code that uses the model to run queries against the database.

Calling a Stored Procedure
Saturday, September 06, 2008 12:30 AM

Instructor Notes (PPT Text)

Explain the steps required to call a stored procedure by using LINQ to SQL.

Student Book Content
In addition, a query expression can contain a further query clause, which is often called a subquery.

Example of a LINQ to SQL Query
In the following code example, the data source consists of the reference to the DataContext class. The query expression contains the three clauses from, where, and select, and the expression is stored in the variable doctorNames. Finally, the for each clause runs the query and iterates through the results. [Visual C#] DoctorsDataContext context1 = new DoctorsDataContext(); var doctorNames = from docs in context1.doctors where docs.city == "Seattle" select docs.dr_fname + " " + docs.dr_lname; foreach (var doc in doctorNames) { ListBox1.Items.Add(doc); }
[Visual Basic] Dim context1 As New DoctorsDataContext Dim doctorNames = From docs In context1.doctors _ Where (docs.city = "Seattle") _ Select docs.dr_fname + " " + docs.dr_lname For Each doc In doctorNames ListBox1.Items.Add(doc) Next

Module 09-Accomplishing Complex Data Access Tasks página 194

Binding a Data Model by Using the LinqDataSource Control
Saturday, September 06, 2008 12:30 AM

Instructor Notes (PPT Text)

If you have time, use a simple demonstration to illustrate the use of the LinqDataSource control. You can use the following high-level steps for this demonstration: 1. Create a new Web site and then add a LINQ to SQL Classes file to the Web site. 2. Add a data connection to the doctors database. 3. Drag the doctors table onto the O/R Designer. 4. Save the .dbml file. 5. Add a LinqDataSource control to the default.aspx Web page. 6. Set the data source property of the LinqDataSource control to the DataContext class that represents the doctors data model. 7. Specify the doctors table and select several columns from the table as the data selection for the LinqDataSource control. 8. Add a list-bound control such as a GridView to the Web page. 9. Set the data source property of the list-bound control to the LinqDataSource control. 10. View the default.aspx page in the browser. If you have time, you can also demonstrate how to create a method by using the right pane of the O/R Designer.

Student Book Content

Binding a Data Model by Using the LinqDataSource Control
Key Points
The LinqDataSource control enables you to display data from a database by using LINQ to SQL but without writing any code at all. You can use a LinqDataSource control to bind to a LINQ data model and then set the DataSourceID of a listbound control to the LinqDataSource control. Question: Describe a scenario when you may use a LinqDataSource control. CD Content

Module 09-Accomplishing Complex Data Access Tasks página 195

Lab - Accomplishing Complex Data Access Tasks
Saturday, September 06, 2008 12:30 AM

Instructor Notes (PPT Text)

In this lab, students will accomplish complex data access tasks from a Web application. Exercise 1 In this exercise, students retrieve data from a Microsoft SQL Server™ database by using a stored procedure. Exercise 2 In this exercise, students access a stored procedure that contains a parameter and bind a SqlDataReader object to a list. Exercise 3 In this exercise, students retrieve data from a Microsoft SQL Server database by using LINQ to SQL. Before the students begin the lab, read the scenario associated with each exercise to the class. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. Remind the students to complete the discussion questions after the last lab exercise. Note: The lab exercise answer keys are provided on the Course Companion CD. To access the answer key, click the link located at the bottom of the relevant lab exercise page.

Student Book Content

Lab: Accomplishing Complex Data Access Tasks
Exercise 1: Get Unique City Names
Scenario
Coho Winery offers several benefits to its employees. In the labs for this course, you will create a Web site that enables employees to select and set up their chosen benefits. One benefit that is offered by Coho Winery is medical insurance. When users apply for medical insurance, they must select a primary care physician. The doctors that are approved by your company are all listed in a SQL Server database that is named doctors. The doctors' specialties are also in the database. In this lab, you will enhance the doctors.aspx page on the Coho Winery Web site to enable users to view the list of specialties for a selected doctor.

Module 09-Accomplishing Complex Data Access Tasks página 196

Exercise 1 - Get Unique City Names
Saturday, September 06, 2008 12:30 AM

Instructor Notes (PPT Text)

One benefit that is offered by Coho Winery is medical insurance. When users apply for medical insurance, they must select a primary care physician. The doctors that are approved by your company are all listed in a SQL Server database that is named doctors. The doctors' specialties are also in the database. In this lab, students will enhance the doctors.aspx page on the Coho Winery Web site to enable users to view the list of specialties for a selected doctor.

Student Book Content
11. Save the changes to the code-behind file. 12. View the doctors.aspx page in the browser. The citiesList list displays the list of cities where the doctors are located. There are no duplicate cities listed. 13. Close the browser window. Results: After this exercise, you have bound the citiesList list on the doctors.aspx page so that the list displays only unique city names from the doctors database.

Module 09-Accomplishing Complex Data Access Tasks página 197

Exercise 2 - Get Doctor Specialties
Saturday, September 06, 2008 12:30 AM

Instructor Notes (PPT Text)

Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. 1. What is the purpose of the GetUniqueCities stored procedure that you call in Exercise 1? To enable the citiesList list on the doctors.aspx page to display a unique list of the available cities. 2. What method can you use to fill a SqlDataReader object from a SqlCommand object? ExecuteReader 3. What steps are required to call the getDrSpecialty stored procedure by using LINQ to SQL? a. Create a new instance of the DoctorsDataContext class. b. Call the getDrSpecialty method of the doctorsContext object and set the DataSource property of the specialtiesListBox control to the result of the method. Pass the drID variable as an argument to the getDrSpecialty method. c. Set the relevant properties of the specialtiesListBox control and call the DataBind method of the control.

Student Book Content

Exercise 2: Get Doctor Specialties
In this exercise, you will display a doctor's specialties in a list. When the user selects a doctor in the doctorsGridViewcontrol, your code will call the getDrSpecialtystored procedure and display the results in the specialtiesListBox control. The main tasks for this exercise are as follows: 1. Call the getDrSpecialtystored procedure. 2. Bind the specialtiesListBox control to the specialtiesSqlDataReader object and make the list visible. Task 1: Call the getDrSpecialty stored procedure 1. In the doctors.aspx page, create a SelectedIndexChanged event procedure for the doctorsGridView control. 2. In the SelectedIndexChanged event procedure, call the CreateDateSet procedure to initialize the connection string for the database. 3. Create a string variable named drID to hold the value of the dr_id column for the row that was selected by the user. 4. Read the value of the dr_id field and store it in the drID variable by using the Cells collection of the SelectedRowof the doctorsGridView. Your code should resemble the following example. [Visual C#] CreateDataSet(); string drID; drID = doctorsGridView.SelectedRow.Cells[1].Text;

Module 09-Accomplishing Complex Data Access Tasks página 198

[Visual Basic] CreateDataSet() Dim drID As String drID = doctorsGridView.SelectedRow.Cells.Item(1).Text 5. Create a new SqlCommand object named specialtiesSqlCommand that uses the doctorsConnection object to call the getDrSpecialtystored procedure. 6. Set the specialtiesSqlCommand command type to a stored procedure.

Module 09-Accomplishing Complex Data Access Tasks página 199

you should provide some high-level hints that might help the students solve the problem stated in the scenarios. doctorsConnection. [Visual Basic] Dim specialtiesSqlDataReader As SqlDataReader doctorsConnection. You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students.Get Doctor Specialties by Using LINQ to SQL Saturday. Fill the specialtiesSqlDataReader object from the specialtiesSqlCommand object by calling the ExecuteReader method of the specialtiesSqlCommand object. In the SelectedIndexChanged event procedure. Create a new SqlDataReader object named specialtiesSqlDataReader.Open() specialtiesSqlDataReader = specialtiesSqlCommand.Exercise 3 . September 06. Student Book Content 11. set the properties for the specialtiesListBox control as Module 09-Accomplishing Complex Data Access Tasks página 200 . data in relational databases. Tools Point out the location from which each key tool can be installed. in-memory data (arrays and lists). Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students.Open(). Open the doctorsConnection SqlConnection object. and data stored in XML documents.ExecuteReader() Task 2: Bind the specialtiesListBox control to the specialtiesSqlDataReader object and make the list visible 1. You can create high-level hints for each scenario by using the following possible solutions for the scenarios. One way to improve the efficiency and security of database access is to create stored procedures on the database server and then call these stored procedures from your Web Form. 2008 12:30 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. 13. If you assign the scenarios as homework. specialtiesSqlDataReader = specialtiesSqlCommand. 12. Remind students that they can use this as a master list to help them gather all the tools required to facilitate their application support work. [Visual C#] SqlDataReader specialtiesSqlDataReader.ExecuteReader(). Why must you use stored procedures instead of accessing the database directly? Direct access and manipulation of data can be a very inefficient use of resources and can create security risks. Let students review the function and usage of each tool on their own. • What types of data can you query with LINQ? DataSet. Your code should resemble the following example. • You must access a database.

specialtiesListBox. In the SelectedIndexChanged event procedure. Property DataSource Value specialtiesSqlDataReader DataTextField "Specialty" 2.DataTextField = "Specialty". [Visual C#] specialtiesListBox. Module 09-Accomplishing Complex Data Access Tasks página 201 . Call the DataBind method of the list. set the properties for the specialtiesListBox control as shown in the following table.DataSource = specialtiesSqlDataReader.DataBind(). Your code should resemble the following example.1. specialtiesListBox.

2008 12:32 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Overview of XML Architecture in ASP. Finally. This lesson explains what an XML document consists of. It also describes XML core technologies.NET Microsoft ASP.NET Saturday. it explains the classes and objects that you use to read and write XML data. These classes and objects represent low-level XML processing components that integrate XML into ASP.Overview of XML Architecture in ASP. Module 10-Reading and Writing XML Data página 202 .NET Web applications. September 06.NET provides various types of classes and objects that you can use to access and synchronize XML data.

Question: How does XML enable you to transfer data across disparate systems? Module 10-Reading and Writing XML Data página 203 . There are examples provided to the students to help them understand the difference between well-formed XML and XML that is not well-formed. Emphasize that XML is case sensitive. 2008 12:32 AM Instructor Notes (PPT Text) This topic explains the content in all of the parts of an XML document. this assists companies in the organization of data. Student Book Content What Is XML? Key Points XML is a universal format that you can use to describe and exchange structured documents and data on the Internet. Point the students to these examples in the student notes and have a small quiz in the class. It then explains well-formed and valid XML. XML fulfills all of these requirements. Ask students to identify the errors in the example of XML that is not well-formed. Companies confront many problems when they organize data because they must fulfill requirements for the content and structure of their data.What Is XML Saturday. September 06.

and retrieve and interpret information from XML data sources. reference elements in XML documents. September 06. Point out the references to W3C. these references provide more detailed information about recommendations and standards related to current and emerging XML technologies.XML Core Technologies Saturday. Question: How can you define an XML document as a schema? Module 10-Reading and Writing XML Data página 204 . Ensure students understand when to use each of these technologies. 2008 12:32 AM Instructor Notes (PPT Text) Emphasize the key features of each technology. transform XML data.org. These technologies enable you to define the structure of XML documents. Student Book Content XML Core Technologies Key Points XML has initiated other technological innovations and developments that work with XML to manipulate data. navigate and edit XML documents.

Module 10-Reading and Writing XML Data página 205 . XML is the standard format for data that is present in DataSet objects. DataSet objects are the basis for disconnected storage and the manipulation of relational data. September 06. and demonstrates how to create nested XML data. DataSet objects are also a container for one or more data tables. 2008 12:32 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 XML and the DataSet Object XML and DataSet objects share a close connection with each other. This lesson explains the relationship between XML and DataSet objects.XML and the DataSet Object Saturday.

XML namespace to synchronize and transform data that is represented by DataSets. Student Book Content Why Use XML with DataSets? Key Points A DataSet is a relational view of data that can be represented in XML. for example. 2008 12:32 AM Instructor Notes (PPT Text) Students must understand the convenience of implementing XML with DataSets.Why Use XML with DataSets Saturday. September 06. to read and write XML data. You can use DataSets to serialize XML data. You can use different XML objects from the System. Question: How can you define the schema of a DataSet? Module 10-Reading and Writing XML Data página 206 . XML and XML schemas provide a convenient format that you can use to transfer the contents of a DataSet to and from remote clients.

Overview of XML and DataSets
Saturday, September 06, 2008 12:32 AM

Instructor Notes (PPT Text)

Ensure that you explain the picture on this slide. The students must understand this overview clearly before they can understand the rest of the module. Point out that the DataSet object is contained in the System.Data namespace and that XmlDataDocument and XslTransform are from the System.Xml namespace.

Student Book Content

Overview of XML and DataSets
Key Points
The Microsoft .NET Framework uses the XML format to store and transmit all types of data. DataSets can store and transmit data in XML format. Question: How can you read an XML document or stream it into a DataSet?

CD Content

Module 10-Reading and Writing XML Data página 207

The XML-Based Methods of the DataSet Object
Saturday, September 06, 2008 12:32 AM

Instructor Notes (PPT Text)

The XML schema is not included in this topic because the ReadXML method can handle well-formed XML.

Student Book Content

The XML-Based Methods of the DataSet Object
Key Points
You can create the contents of a DataSet from an XML stream or document. The .NET Framework provides great flexibility for loading XML data and creating the schema or relational structure of a DataSet. Question: How can you obtain the XML representation of the DataSet as a string?

CD Content
You can create the contents of a DataSet from an XML stream or document. In addition, the .NET Framework provides great flexibility for loading XML data and creating the schema or relational structure of a DataSet.

Module 10-Reading and Writing XML Data página 208

Creating Nested XML Data
Saturday, September 06, 2008 12:32 AM

Instructor Notes (PPT Text)

Ensure that the students understand that they must set the Nested property of the DataRelation to true.

Student Book Content

Creating Nested XML Data
Key Points
You can implement the relationship between tables in a DataSet by using a DataRelation. In the hierarchical representation of data that XML provides, the parent-child relationships are represented by parent elements that contain nested child elements. You can set the Nested property of a DataRelation to true to create nested XML data. Question: What is the default value of the Nested property of a DataRelation?

Module 10-Reading and Writing XML Data página 209

Demonstration - Creating Nested XML
Saturday, September 06, 2008 12:32 AM

Use this demonstration for further explanation about how to create nested XML. The lab contains an If Time Permits exercise about nested data; therefore, students may not have a chance to practice this activity for themselves. Mention that you can optionally write the schema to the output. Also mention that the default option is to IgnoreSchema and not write the schema to the output. In this demonstration, students will see how to create a nested XML document. Note: This demonstration contains a complete solution. • To run the demonstration 1. In Microsoft® Visual Studio® 2008, create a Web site. 2. Add the SaveNestedXML.aspx page from the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder to the Web site. 3. View the code-behind page, explain the code, and then point out the following: • In the CreateDataSet function, a DataSet with two DataTables is created. • In the MakeDataRelation function, a DataRelation is created between the two tables, setting the Nested property to True or False depending on the argument to the function. • In the saveXMLButton_Click event procedure, the DataRelation is created with Nested set to false, and then the DataSet is written to an XML file. • In the saveNestedXMLButton_Clic k event procedure, the DataRelation is created with the Nested property set to true, and then the DataSet is written to an XML file. 4. Build and browse the SaveNestedXML.aspx page. 5. In the browser, click Save as XML. This is the XML data that was created from the DataSet with the Nested property set to false. Point out that the doctors elements are all listed, followed by the drspecialties elements. 6. In the browser, click the back button, and then click Save as Nested XML. This is the XML data that was created from the DataSet with the Nested property set to True. Point out that the doctors elements are nested inside the related drspecialties elements. 7. Close the browser.

Instructor Notes (PPT Text)

Student Book Content

Demonstration: Creating Nested XML
Question: How can you tell that the XML data is nested?

CD Content
In this demonstration, the instructor will show you how to create a nested XML document.

Module 10-Reading and Writing XML Data página 210

Managing XML Data
Saturday, September 06, 2008 12:33 AM

Instructor Notes (PPT Text)

Student Book Content
Lesson 3

Managing XML Data
The XmlDataDocument class enables you to store, retrieve, and manipulate XML documents by using a relational DataSet. XmlDataDocument provides a relational view of the loaded XML document and has a close affiliation with the DataSet class. Any changes that are made to one object are reflected in the other. Similarly, to transform the contents of a source XML document into another format such as XML or HTML, you can use XSL transformations. This lesson explains how to synchronize a DataSet with an XmlDataDocument. It also describes how to use XmlDataDocument. Finally, it explains how to transform XML data by using the XslCompiledTransform object.

Module 10-Reading and Writing XML Data página 211

Overview of Synchronizing a DataSet with an XmlDataDocument
Saturday, September 06, 2008 12:33 AM

Instructor Notes (PPT Text)

Students must understand that the ADO.NET DataSet is relational and the XML classes are hierarchical. However, you can access both synchronously by using DataSet and XMLDataDocume nt respectively.

Student Book Content

Overview of Synchronizing a DataSet with an XmlDataDocument
Key Points
The DataSet object enables real-time, synchronous access to the relational representations of data. The XmlDataDocument object enables real-time, synchronous access to the hierarchical representations of data. When a DataSet is synchronized with an XmlDataDocument, both objects work with the same single set of data. Question: When you make a change to a DataSet, what happens to the XmlDataDocument if both objects are synchronized?

Module 10-Reading and Writing XML Data página 212

September 06. Module 10-Reading and Writing XML Data página 213 . Store a DataSet in an XmlDataDocument. Student Book Content Synchronizing a DataSet with an XmlDataDocument Key Points You can synchronize a DataSet with an XmlDataDocument by storing XML data in an XmlDataDocument or a DataSet in an XmlDataDocument. Question: How can you store a DataSet in an XmlDataDocument? CD Content There are two ways to synchronize a DataSet with an XmlDataDocument. You can: Store XML data in an XmlDataDocument. 2008 12:33 AM Instructor Notes (PPT Text) Ensure that the students understand how to use the XmlDataDocument object.Synchronizing a DataSet with an XmlDataDocument Saturday.

Also ensure that you use the innerText property to retrieve the data. Student Book Content Manipulating an XmlDataDocument Key Points The XmlDocument implements the Document Object Model (DOM) in XML. do not use ToString. The XmlDataDocument unifies ADO. 2008 12:33 AM Instructor Notes (PPT Text) Ensure that the students understand how to manipulate an XmlDataDocument instance. XElement is used by LINQ.NET and XML by representing relational data from a DataSet and synchronizing that data with the XML document model.Manipulating an XmlDataDocument Saturday. Note: If you choose to demonstrate the content in this topic. ensure that you declare an XmlElement and not an XElement. September 06. Question: How can you extract individual rows as XML from a DataSet? CD Content Module 10-Reading and Writing XML Data página 214 .

2008 12:33 AM Instructor Notes (PPT Text) Ensure that students understand the use of the XslCompiledTrans form object. You can use the Transform method of an XslCompiledTransform object to transform the data.Transforming XML Data by Using XSLT Saturday. The transform method can also contain an argument of type XsltArgumentList. Explain that XslTransform has been depreciated. and it is easier to manage smaller Xsl files. In the . where an object can be passed to the transform method. It is more efficient to pass an object here than to rely on scripts in the Xsl file by using tags. Student Book Content Transforming XML Data by Using XSLT Key Points You can use XSL transformations to transform the content of a source XML document into another document that is different in format or structure. Question: Why does the Transformmethod have several overloads? Module 10-Reading and Writing XML Data página 215 . the XslCompiledTransformclass is the XSLT processor that transforms one XML document into another. September 06.NET Framework.

View the page in a browser.aspx page in Design view.aspx and doctors_style. The two GridView controls display the two DataTables in the DataSet. 8. 2. Note: This demonstration contains a complete solution. • The Transform method of the XslCompiledTransform object is called to apply the style sheet to the XmlDocument. 7. Point out the code in the transformButton_Clic k event procedure and explain the code: • The DataSet is created by calling CreateDataSet to create the DataSet. Open the doctors_style. create a Web site or continue with the Web site from the previous demonstration. you must first add the doctors parent table to the DataSet.xsl style sheet. In this demonstration. This is the HTML page that was created from the DataSet data. In Visual Studio 2008. 9. Point out to the students that the Transform method can only output to an XmlReader. click Transform Data. students will see how to transform data by using the XslCompiledTransform object. 6. In the browser.xsl files from the E:\Labfiles\Democode\CS or E:\Labfiles\Democode\VB folder to the Web site. or to XmlWriter objects. September 06. View the code-behind page.xsl style sheet to show how it works. before the drspecialties table. 2008 12:33 AM Use this demonstration to illustrate the topics from this lesson as you discuss them. the instructor will show you how to transform data by using the XslCompiledTransform object. • To run the demonstration 1.Demonstration . Close the browser. and then click the View Transform Output hyperlink. 4. a TextReader. Add the Transform. 3.Transforming Data by Using XSLT Saturday. • An XmlDataDocument is created from the DataSet. 5. Module 10-Reading and Writing XML Data página 216 . for the XmlDataDocument mapping to work. Instructor Notes (PPT Text) Student Book Content Demonstration: Transforming Data by Using XSLT Question: What does the Transformmethod of the XslCompiledTransformobject perform? CD Content In this demonstration. However. the DataSet then calls MakeDataRe lation to create the DataRelation. Open the Transform. • An XslCompiledTransform object is created and loaded by using the doctors_style.

Module 10-Reading and Writing XML Data página 217 . September 06. 2008 12:33 AM Instructor Notes (PPT Text) Student Book Content Lesson 4 Accessing XML Data by Using the XML Web Server Control Information in an XML file is raw.Accessing XML Data by Using the XML Web Server Control Saturday. load. To display XML data in a Web Forms page. This lesson explains how to display. you must provide formatting and display information. the file contains only the data and no indication about how to format or display this information. and save XML data.

2008 12:33 AM Instructor Notes (PPT Text) Explain that students can use the Xml Web server control to write an XML document or the results of an XSLT transformation to a Web page. Also explain that the XML output appears in the Web page at the location of the control. Point out to the students that this achieves the same results as the previous demonstration by using the Xml control instead. save the nested DataSet from the previous demonstration.What Is the XML Web Server Control Saturday. The output is a new file with the XML information formatted according to the transformation file. September 06. Note: Use a simple demonstration as you discuss the topics in this lesson. Question: Where does the XML output of the control appear on the Web page? Module 10-Reading and Writing XML Data página 218 . add a new Web Form that contains the Xml control. Student Book Content What Is the XML Web Server Control? Key Points You can use the XSL Transformation language to specify the tags that display XML data and provide instructions about how the data from an XML file fits into these tags. You can use the XML Web server control to write an XML document or the results of an XSL Transformation to a Web page. and then set the DocumentSource and TransformSource attributes. If time permits.

and including the XML content inline. Question: How can you transform the XML document before its contents are written to the output stream? Module 10-Reading and Writing XML Data página 219 . ensure that the students understand the three different methods that they can use to load XML data into a Microsoft ASP . September 06. Similarly. 2008 12:33 AM Instructor Notes (PPT Text) Ensure that the students understand the two methods that you can use to add an XML Web server control to a Web Form. loading an XML document as an object.Loading and Saving XML Data Saturday. Student Book Content Loading and Saving XML Data Key Points You can create an Xml control by adding it from the Toolbox to a Web page or programmatically in code.NET Web application. You can load XML data into a Web application by providing a path to an external XML document.

Exercise 3 In this exercise. Exercise 2 In this exercise. Module 10-Reading and Writing XML Data página 220 . students will read. you will read mutual fund data from an XML file and then read.xml file and store them in a DataSet. September 06. Note: The lab exercise answer keys are provided on the Course Companion CD. and display XML data. Remind the students to complete the discussion questions after the last lab exercise. In this exercise. read the scenario associated with each exercise to the class. To access the answer key. You will then display the DataSet in a GridViewcontrol. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. Before the students begin the lab. click the link located at the bottom of the relevant lab exercise page. Exercise 1 In this exercise. One benefit that is offered by Coho Winery is the retirement benefit. and display a prospectus for a specified mutual fund.Lab . they can view the prospectuses of several mutual funds that are offered by Coho Winery.Reading XML Data Saturday. transform. Student Book Content Lab: Reading XML Data Exercise 1: Reading a List of Mutual Funds from an XML File Scenario Coho Winery offers several benefits to its employees. you will read a list of mutual funds from the mutual_funds. students read an XML file and store it in a DataSet. students apply transformation to an XML file. students create nested XML data from a SQL Server database. When users apply for the retirement benefit. In this lab. 2008 12:33 AM Instructor Notes (PPT Text) In this lab. you will create a Web site that enables employees to select and set up their chosen benefits. In the labs for this course. transform.

In a change from the previous response. Student Book Content [Visual Basic] 'myDataRelation2. 19. Note: You cannot use the two nested relationships at the same time because the same DataTable (drspecialties) cannot be a child in two nested relations.Reading a List of Mutual Funds from an XML File Saturday. Tip: You may have to refresh the browser after the page loads to see the changes to the XML data. For this reason. September 06. On the File menu. 17. they can view the prospectuses of several mutual funds that are offered by Coho Winery.Exercise 1 . click Save All. you have experimented with nested XML data from a SQL Server database. 2008 12:33 AM Instructor Notes (PPT Text) One benefit that is offered by Coho Winery is the retirement benefit. Module 10-Reading and Writing XML Data página 221 . In Solution Explorer. When users apply for the retirement benefit. and then click View in Browser. at the beginning of the file. 18. then the specialties and drspecialtiesare nested (for every specialty.Nested = True 16. all of the doctors are now listed sequentially. right-click nestedData. analyze the XML data. Close the browser.aspx. In the browser. Results:After this exercise. you have commented out the nested property setting from the previous exercise. all of the drspecialtieschildren are listed).

Where is the information for the mutual funds stored? The information for the mutual funds is stored in an XML file named mutual_funds. 2. When you read data into the DataSet. You can also synchronize a DataSet object with an XmlDataDocument object.xml. How did you apply a transformation to the Xml control? By Setting the TransformSource property of the Xml control to the correct . why did you use the Server. The title of the prospectus page is Prospectus and the text General Description is in the color brown. retrieved. Transforming. Why did you use an Xml control? The Xml control displays the content of the lgcap. 3.Reading.Exercise 2 . Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. 1. 2008 12:33 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. 5.MapPath method? You can use the Server.xsl file.xsl file is an XML style sheet that uses XSLT to display XML data. and manipulated by using a relational DataSet object.xml prospectus as a continuous.MapPath method to return the physical file path that corresponds to the specified virtual path that is on the Web server for the current request. What is the prospectus_style.xsl file and what is its purpose? The prospectus_style. Student Book Content The XmlDataDocument class enables structured data to be stored. September 06. 4. unformatted string of text. and Displaying XML Saturday. Module 10-Reading and Writing XML Data página 222 .

What XML technology must you use? XQuery • You want to navigate and edit XML information. • You want to reference elements in an XML document. What XML technology must you use? DOM Best Practices Help the students understand the best practices presented in this section. 2008 12:33 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. What XML technology must you use? XPath • You want to retrieve and interpret XML information. You can create high-level hints for each scenario by using the following possible solutions for the scenarios.Nested Data Saturday. If you assign the scenarios as homework. Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students. You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students. September 06.Exercise 3 . Student Book Content Module 10-Reading and Writing XML Data página 223 .(If Time Permits) . Ask students to consider these best practices in the context of their own business situations. you should provide some high-level hints that might help the students solve the problem stated in the scenarios.

NET AJAX Application página 224 .NET AJAX ASP. 2008 12:34 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Introduction to ASP. September 06.NET AJAX technologies and describes the architecture of ASP.NET AJAX Saturday.NET AJAX uses client-script libraries and server components to implement Ajax features.NET AJAX. Module 11-Creating a Microsoft ASP. This lesson introduces the Ajax and ASP.Introduction to ASP.

XHTML. XML and other data transfer formats such as JavaScript Object Notation (JSON). HTML. including: XMLHttpRequest object. you can refresh parts of a page instead of the whole Web page when you must exchange data with the Web server. HTML.NET AJAX Application página 225 . which you can use to transfer data between a Web server and a client. which you use with a scripting language such as JavaScript to provide client-side interaction with the data in a Web page. Mention that one of the key features of Ajax is the XMLHttpRequest object. 2008 12:34 AM Instructor Notes (PPT Text) Briefly explain the background and history of Ajax. XML and other data transfer formats such as JavaScript Object Notation (JSON). including the following: XMLHttpRequest object. which provide the markup and style information for a Web page. Document Object Model (DOM). Student Book Content What Is Asynchronous JavaScript and XML? Key Points Ajax uses several technologies. and cascading style sheets. CD Content Ajax is a group of technologies that is designed to increase the responsiveness of Web pages.What Is Asynchronous JavaScript and XML Saturday. By using Ajax. Document Object Model (DOM). September 06. and cascading style sheets. This increases the speed and interactivity of the page. This object enables browsers to request data without a page reload and is one of the key features of Ajax. Do not spend too much time on this topic. Ajax Technologies AJAX makes use of several technologies. Ajax works across multiple platforms and browsers and uses open standards such as JavaScript. XHTML. The asynchronous nature of Ajax means that your application can retrieve data from the server as a background task that does not affect the current Web page display. Module 11-Creating a Microsoft ASP. which you use to exchange data with the Web server asynchronously. This object enables browsers to make asynchronous data requests without the requirement to reload pages.

NET AJAX Application página 226 .com/fwlink/?LinkId=111443 Student Book Content Module 11-Creating a Microsoft ASP. do not go into detail because the next topic explains the architecture further.NET AJAX consists of client-script libraries and server components.NET AJAX is to improve the efficiency of Web applications and therefore to enhance the user experience for users of an application.What Is ASP.NET AJAX Saturday. September 06. 2008 12:34 AM Instructor Notes (PPT Text) The key point is that the goal of ASP. Reference: http://go. However. Mention that ASP.microsoft.

NET AJAX Saturday.NET AJAX Key Points The client architecture of ASP. September 06.NET AJAX consists of ASP. CD Content ASP. 2008 12:34 AM Instructor Notes (PPT Text) Explain that the client-script libraries and server components integrate to produce the development environment. References: http://asp.Architecture of ASP. The server architecture of ASP.NET Web server controls and components that you use to create the User Interface (UI) and implement the functionality of an application.NET AJAX consists of client-script libraries and server components.aspx Student Book Content Architecture of ASP.NET AJAX is made up of client-script libraries that are composed of JavaScript files.net/ajax/documentation/live/overv ie w/de fault.NET AJAX Application página 227 . Module 11-Creating a Microsoft ASP.

NET AJAX Extensions The ASP.0 AJAX Extensions provide server-side controls and functionality that you use to implement ASP. September 06. This lesson describes the Extensions and explains how to use several of the available ASP. Module 11-Creating a Microsoft ASP.NET 2.Creating an ASP.NET AJAX features in your Web applications.NET AJAX Extensions Saturday.NET AJAX Application página 228 .NET AJAX Application by Using the ASP. 2008 12:34 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Creating an ASP.NET AJAX server controls.NET AJAX Application by Using the ASP.

Web. The Extensions extends the server-side control framework of ASP.Script.Web.0 AJAX Extensions programmatically. Provides classes and interfaces that enable client-server communication and rich UIs through the use of the ASP.NET 2.UI. 2008 12:34 AM Instructor Notes (PPT Text) Emphasize that the ASP.0 AJAX Extensions is included with Microsoft Visual Studio ® 2008 and is available as a separate download for Visual Studio 2005. Services System.NET AJAX Application página 229 .NET AJAX Extensions? Key Points The ASP.Handle Contains HTTP Handler classes that process HTTP requests to a Web server.NET AJAX Extensions is included with Microsoft® Visual Studio® 2008 but can also be downloaded for Visual Studio 2005. Student Book Content What Are the ASP.NET AJAX Extensions are implemented in several namespaces. The features of the ASP. Contains classes that provide JSON serialization and deserialization for managed types.Web. Namespace System.UI Provides attributes to customize Web service support for the ASP. rs System.Web.0 AJAX Extensions.Configuration and System. Version 2.5 and Microsoft Visual Studio ® 2008. These controls appear in their own tab in the Visual Studio Toolbox.NET 2.NET 2.NET Framework 3.NET AJAX. The following table describes these namespaces.0 of the Extensions is included with the .NET 2. It Serialization also provides extensibility features to customize serialization behavior. System. September 06.What Are the ASP.NET AJAX Extensions Saturday.Web.0 AJAX gn Extensions. CD Content The ASP.Web.UI. System.0 AJAX Extensions is available as a separate download for Visual Studio 2005. Note: The ASP.Config uration Description Contains classes that enable you to configure the ASP. including System. Server Namespaces The features of the ASP. System.NET and provide several new controls that you use to implement Ajax features in your Web applications.NET 2.NET 2.Desi Contains classes that you can use to extend design-time support for ASP.NET AJAX Extensions are implemented in several namespaces. Module 11-Creating a Microsoft ASP.Script.NET AJAX Extensions contains the core server-side components of ASP.Web.0 AJAX Extensions.Web.

September 06. Student Book Content Module 11-Creating a Microsoft ASP.NET AJAX Application página 230 .NET AJAX Server Controls Saturday. 2008 12:34 AM Instructor Notes (PPT Text) Give a brief overview of each of the most commonly used server controls. Explain that the UpdatePanel and ScriptManager controls will be demonstrated in the next topic.ASP.

Now. 2008 12:34 AM Instructor Notes (PPT Text) In this demonstration. [Visual Basic] Label1.aspx page. Module 11-Creating a Microsoft ASP. 21. delete the Inside Panel button. add a Button control to the form. extend the demonstration to include an example of how to use the UpdateProgress control. add a Label control. To run the demonstration 1.aspx page.ToString(). On the form. 6. and then view the default. 7.Close the browser window. 3. students will see a simple example of how to use the UpdatePanel control to provide partial-page rendering.Add code to the Click event handler to set the Text of the Label to the string Current Time: followed by the current date and time.aspx page in Design view.Close the browser window.On the Triggers property click the ellipsis.NET Web site. 5.Click Outside Panel several times and verify that the content in the label changes but a page refresh does not occur. 13. Note: If you have time. When you begin the demonstration. click Add. you will see how to implement an UpdatePanel control in a Web application. and then view the page in the browser. explain that the ScriptManager control is required because it provides the support for partial-page rendering.Text = "Current Time: " + DateTime. 10. 4. Click each button in turn and verify that the button inside the UpdatePanel does not cause a page postback but the button outside of the panel does cause a postback.Demonstration . Create a new ASP. Add a ScriptManager and UpdatePanel to the page. add a second Button control. Open the default.Double-click Outside Panel to create a Click event handler. and then click OK. 11. 9.ToString() 15.aspx page. Set the Text property of the button to the value Inside Panel. Set the Text property of the second button to the value Outside Panel.On the form.aspx page in the browser. Save the default.Now. 2. 19. inside the UpdatePanel. 12.NET AJAX Application página 231 .Implementing the UpdatePanel Control Saturday.Set the ControlID property of the new trigger to Button2.Text = "Current Time: " & DateTime.Save the Web site. Student Book Content Demonstration: Implementing the UpdatePanel Control In this demonstration. 20. 22. 8.In the UpdatePanelTrigger Collection Editor dialog box.View the properties of the UpdatePanel control. [Visual C#] Label1. September 06. Also explain that partial-page rendering is a useful feature because it removes the requirement for the whole page to be refreshed as the result of a postback. 18.Switch to Design view of the default. Explain to the students that you can also configure a control outside the UpdatePanel as a trigger that refreshes just the UpdatePanel. 14. 17.In the default. In the UpdatePanel. 16. outside the UpdatePanel.

an instance of the PageRequestManager class becomes available to the page. Briefly explain the available events and step through the example code provided. Question: What are some scenarios when you may want to handle the events of the PageRequestManager class? CD Content Module 11-Creating a Microsoft ASP. Reference: http://go. Get a reference to the current instance of the PageRequestManager class by calling the getInstance method and then create a function to handle the required event. 2008 12:34 AM Instructor Notes (PPT Text) Mention that you do not create an instance of the PageRequestManager directly.Managing Partial-Page Updates Saturday. September 06.com/fwlink/?LinkId=111444 Student Book Content Managing Partial-Page Updates Key Points When you implement partial-page rendering on a Web page. You use JavaScript in your Web page to handle the events raised by the PageRequestManager class. it is available automatically when you enble partial-page rendering.NET AJAX Application página 232 .microsoft.

NET AJAX. args) { .add_beginRequest (ReqHandler). function ReqHandler(sender. 2008 12:34 AM Instructor Notes (PPT Text) Emphasize that when you create a Web site by using Visual Studio 2008.microsoft. <script type="text/javascript" language="javascript"> Sys. The example also specifies a function to use to handle the beginRequest event of the class. The following code example demonstrates how to get a reference to the current instance of the PageRequestManager class by calling the getInstance method.Converting an ASP.NET AJAX application.. September 06. it is already an ASP. Reference: http://go.PageRequestManager. Explain that the web.config file requires several new elements if you want to convert an application to use ASP. } </script> Module 11-Creating a Microsoft ASP.getInstance()..NET AJAX Saturday.com/fwlink/?LinkId=110717 Student Book Content Implementing a PageRequestManager Event You use JavaScript in your Web page to handle the events raised by the PageRequestManager class.NET AJAX Application página 233 .WebForms.NET Application to ASP.

NET AJAX Control Toolkit Saturday. and use the Toolkit.NET AJAX Control Toolkit The AJAX Control Toolkit provides more than 30 different controls and extenders that you can use to enhance your Web applications.Extending an Application by Using the ASP. install. September 06. This lesson describes how to download. Module 11-Creating a Microsoft ASP.NET AJAX Application página 234 . 2008 12:34 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Extending an Application by Using the ASP.

This folder contains an installer file for templates to create new extender controls.microsoft. AjaxControlExtender folder.NET AJAX community and Microsoft.NET AJAX Control Toolkit is a shared-source project between the ASP. SampleWebsite folder. September 06. Question: What advantages does the AJAX Control Toolkit provide? CD Content The ASP. Note: There is a difference between extenders and controls. 2008 12:34 AM Instructor Notes (PPT Text) Give a brief overview of the ASP. Extenders add to an existing control but do not change the core functionality of the control. You can also use the infrastructure of the Toolkit to write reusable and extensible ASP.microsoft. ToolkitTests folder. The Toolkit contains several folders of content. including the following: AjaxControlToolkit folder. This folder contains demonstrations of the controls. Controls provide new functionality. This folder contains automated tests for all controls. including the following: AjaxControlToolkit folder.NET AJAX Extensions and contains a collection of Web-client components that you can use to enhance your Web applications.com/fwlink/?LinkId=111446 Student Book Content Overview of the ASP.NET AJAX Control Toolkit Key Points The Toolkit contains several folders of content.com/fwlink/?LinkId=111445 http://go.Overview of the ASP.NET AJAX Application página 235 . AJAX Control Toolkit Content You download the AJAX Control Toolkit in the form of a zip file.5 and Visual Studio 2008.NET Framework 3.NET AJAX Control Toolkit and explain the components that it provides.NET AJAX extenders and controls. typically by wrapping an existing control.NET AJAX controls that the Toolkit provides. Reference: http://go. Module 11-Creating a Microsoft ASP. The Toolkit is built on the ASP. This folder contains source code for the controls that the Toolkit provides.NET AJAX Control Toolkit Saturday. Mention there are over 30 controls and extenders available and that the Toolkit has recently been updated to target the official release of the Microsoft . This folder contains the source code for the set of sample ASP.

microsoft. Reference: http://go.NET AJAX Control Toolkit Saturday.microsoft. you must download it.NET AJAX Control Toolkit Key Points You can download the Control Toolkit from the following location: http://go.NET Framework 3.com/fwlink/?LinkId=111448 Student Book Content Accessing the ASP.microsoft.NET AJAX Application página 236 . September 06. Module 11-Creating a Microsoft ASP.com/fwlink/?LinkId=111447 http://go. 2008 12:34 AM Instructor Notes (PPT Text) Briefly explain the steps required to download and install the Toolkit.5 and Visual Studio 2008. You can then add the Toolkit controls to the Toolbox in Visual Studio 2008 and install the provided templates. CD Content Before you can use the AJAX Control Toolkit.Accessing the ASP.com/fwlink/?LinkId=110718 The most recent version of the Toolkit targets the official release of the Microsoft .

aspx page in the browser.dll file. Open the default. and then close the browser window.aspx Web form in Design view. 11. Student Book Content Demonstration: Implementing an ASP. 12.Implementing an ASP. students will see how to create a sample Web application that uses several features and controls of the Control Toolkit. Note: This demonstration requires the AjaxControlToolkit. set the ConfirmText property of the ConfirmButtonExtender control to Continue?. on the AJAX Extensions tab.dll file that targets the official release of .NET Framework 3. In the Toolbox. create a tab named AJAX Control Toolkit.Click the button and verify that the confirmation dialog box appears. Add the items from the file E:\Democode\AjaxControlToolkit. add a Label and Button control to the form.dll to the AJAX Control Toolkit tab. Use the steps in the topic Accessing the ASP. 2.NET AJAX Control Toolkit to perform the demonstration. 5.View the default. drag a ScriptManager and drop it at the top of the form. Show the new Toolbox items. extend the demonstration to show how to install the the AJAX Control Toolkit templates.Demonstration .In the Toolbox. September 06.5 and Visual Studio 2008.In the Toolbox.codeplex. In the event handler. download it from the www. 14. on the AJAX Control Toolkit tab. 13.NET Web application.NET AJAX Extender Control Saturday. 4. View the default. Module 11-Creating a Microsoft ASP. Create a new ASP. 7. you will see how to implement a ConfirmButtonExtender control in an ASP. add code to set the Text property of the label to the string Button click occurred. 8. If you have time. On the form.com Web site and copy it to the E: \Democode\ folder in the virtual machine. drag a ConfirmButtonExte nder and drop it onto Button1 on the form. 9.aspx page in the browser. To run the demonstration: 1.NET Web site. and then click the button on the page. Verify that the label text changes. 3.NET AJAX Application página 237 . 6.NET AJAX Extender Control In this demonstration.In the Properties window. Create a Click event handler for the button. If the virtual machine does not contain the AjaxControlToolkit. 10. 2008 12:34 AM Instructor Notes (PPT Text) In this demonstration. Mention to the students that the techniques used here to extend the button will be used in the lab to extend a textbox with a calendar.

NET AJAX Extensions to implement partial-page rendering when the user selects a different doctor or moves to a new page in the list of doctors.NET AJAX Control Toolkit and then use the CalendarExtender control to enhance the nameDate user control. 2008 12:34 AM Instructor Notes (PPT Text) In this lab. Exercise 2 In this exercise.NET Framework 3.com Web site and distribute the file to the students. Before the students begin the lab. students implement partial-page rendering with the UpdatePanel control.NET AJAX application.NET AJAX Application Exercise 1 Implementing Partial-Page Rendering by Using the UpdatePanel Control Scenario The doctors. you will use the ASP. Ensure the students copy the file to the E:\Labfiles\Starter\ folder in the virtual machine.codeplex. In this exercise. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. Student Book Content Lab: Creating a Microsoft ASP.dll file that targets the official release of . you will implement partial-page rendering. Download this file from the www. read the scenario associated with each exercise to the class. In this lab. September 06. Note: Exercise 2 requires the AjaxControlToolkit. Module 11-Creating a Microsoft ASP. students will create an ASP.Creating a Microsoft ASP. Exercise 1 In this exercise.NET AJAX Application Saturday.NET AJAX Application página 238 .5 and Visual Studio 2008. Remind the students to complete the discussion questions after the last lab exercise. You will also install the controls from the AJAX Control Toolkit and use the CalendarExtender control to enhance the nameDate user control.aspx page on the Coho Winery Web site enables users to view the list of specialties of a selected doctor.Lab . Note: The lab exercise answer keys are provided on the Course Companion CD. students install the ASP. click the link located at the bottom of the relevant lab exercise page. To access the answer key.

aspx page on the Coho Winery Web site enables users to view the list of specialties of a selected doctor. 3. Where to find it Available for download. You can also use the templates provided by the Toolkit to build your own controls and extenders. How can you use the AJAX Control Toolkit to enhance your applications? The Toolkit provides many prebuilt controls that you can add to your applications quickly.Implementing Partial-Page Rendering by Using the UpdatePanel Control Saturday. Students will also install the controls from the AJAX Control Toolkit and use the CalendarExtender control to enhance the nameDate user control. and globalization. 2008 12:34 AM Instructor Notes (PPT Text) The doctors. September 06. students will use the ASP.NET AJAX Extensions and contains a collection of Web-client components that you can use to enhance your Web applications. 2.NET AJAX Application página 239 . What features does the ScriptManager control provide? Management of script resources and features such as partial-page rendering. localization. What is the design goal of the AJAX group of technologies? To increase the responsiveness of Web pages. Module 11-Creating a Microsoft ASP. In this lab. Student Book Content Tools Tool AJAX Control Toolkit CD Content Use for Built on the ASP. Review Questions 1.NET AJAX Extensions to implement partial-page rendering when the user selects a different doctor or moves to a new page in the list of doctors.Exercise 1 .

What steps are required before you can use a control from the AJAX Control Toolkit? Download the Toolkit and add the controls from the Toolkit to a new tab in the Toolbox.Installing and Implementing the AJAX Control Toolkit Saturday. You can then add a control from the Toolbox to your Web page. September 06. Student Book Content Module 11-Creating a Microsoft ASP. 1.NET AJAX Application página 240 . 2008 12:34 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises.Exercise 2 . What controls must you add to a page to implement partial-page rendering? ScriptManager and UpdatePanel 2. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section.

and describes the main tools that you can use to develop Silverlight content. This lesson introduces the features of Silverlight. cross-platform plug-in that you can use to deliver media experiences and rich interactive applications on the Internet by using XAML. 2008 12:35 AM Instructor Notes (PPT Text) It is important to stress that Microsoft® Silverlight™ in still in the early stages of development. explains the component architecture of Silverlight.Overview of Microsoft Silverlight Saturday. Student Book Content Lesson 1 Overview of Microsoft Silverlight Silverlight is a cross-browser. Silverlight also offers powerful functionality that improve the productivity of both designers and developers. September 06. Module 12-Delivering Dynamic Content with Microsoft Silverlight página 241 .

Module 12-Delivering Dynamic Content with Microsoft Silverlight página 242 . Mention that the extensions to Microsoft JScript® provide control over browser UIs.microsoft. References: http://go. You can publish media content that operates on different platforms and create video applications that have similar functionality to DVD players. Silverlight includes Windows Presentation Foundation (WPF) technology that enables you to create rich client features that are not available with HTML alone. 2008 12:35 AM Instructor Notes (PPT Text) Mention to the students that Silverlight is based on Windows Presentation Foundation (WPF) and Extensible Application Markup Language (XAML) technology. Silverlight extends JScript to provide powerful control over browser user interfaces (UIs).com/fwlink/?LinkId=111450 Student Book Content Key Features of Microsoft Silverlight Key Points Silverlight offers numerous features that you can use to create truly immersive experiences.microsoft. You can use XAML to create WPF elements.Key Features of Microsoft Silverlight Saturday. Mention that media experiences include high quality video and audio.com/fwlink/?LinkId=111449 http://go. September 06. Emphasize that familiarity with Silverlight will be an advantage when they move on to the rest of WPF.

Student Book Content Tools for Designing and Developing Silverlight Applications Key Points You can use the professional design tools in Microsoft Expression Studio to create rich content and the development environment of Visual Studio to generate interactive functionality.Tools for Designing and Developing Silverlight Applications Saturday. Question: What are the similarities and differences between Expression Studio and Visual Studio? Module 12-Delivering Dynamic Content with Microsoft Silverlight página 243 . September 06. 2008 12:35 AM Instructor Notes (PPT Text) Differentiate between the Microsoft Expression® applications. designers and developers can collaborate more effectively to deliver Web solutions. which you can use to design Silverlight applications. which you can use to develop an application. and Microsoft Visual Studio®. By using these tools. Note: Many of the Silverlight tools are in early release versions or previews.

A Silverlight application first invokes the Silverlight control from the HTML page. and timelines by using XAML.Architecture of Silverlight Saturday. Windows Media Audio (WMA). September 06. automatic updates. which then loads a XAML file.NET Framework.microsoft. Briefly mention that the installer and updater control helps first-time users to install the application and provides for subsequent low-impact. retrieve objects by using JScript. However. Windows Media Video (WMV).NET Framework for Silverlight is a subset of the full . and stream multimedia content. 2008 12:35 AM Instructor Notes (PPT Text) • • • • • • • • • • • • The core presentation components for Silverlight are as follows: Input UI Rendering Media Controls DRM XAML The .NET Framework languages became available with the Alpha 1. do not spend too much time on this component. The plug-in provides mechanisms at run time to change the XAML content. animations.1 Refresh release.com/fwlink/?LinkId=110698 Student Book Content Architecture of Silverlight Key Points Silverlight is a browser plug-in for constructing graphics. Reference: http://go. Silverlight contains the codecs to play VC-1. Question: How does AJAX relate to Silverlight? Module 12-Delivering Dynamic Content with Microsoft Silverlight página 244 . and MP3 multimedia content. Explain that full support for the . You can then attach the XAML to JScript code to implement functionality.NET Framework components for for Silverlight are as follows: WPF Data Base Class Library Networking CLR DLR Mention that the .

and much more. Question: How does Silverlight relate to XAML? Module 12-Delivering Dynamic Content with Microsoft Silverlight página 245 . Explain that the separation of the UI and the logic that drives it enables designers and developers to work on a project independently. it enables you to incorporate vector images. Therefore. video. However. Reference: http://go. Note: XAML is a core component of the Windows Presentation Foundation that you can use to design the UI of rich Microsoft Windows®-based applications. A XAML file typically contains a Canvas root element that you can use to contain objects and tags to define objects.com/fwlink/?LinkId=111451 Student Book Content XAML and Microsoft Silverlight Key Points XAML is a declarative markup language that you can use to define all aspects of the UI for your Silverlight application. where students first design the UI and then add code to implement interactivity.XAML and Microsoft Silverlight Saturday. XAML files are simple because they are just plain text files. XAML is much richer than HTML. This is emphasized in the lab at the end of the module. It is also possible to identify event procedures by using XAML.microsoft. September 06. hence the requirement for a more visual design tool like those available in Expression Studio. XAML is not tied to either just WPF or just Silverlight. this very powerful markup language is applied to Silverlight to take full advantage of enhanced UI features. 2008 12:35 AM Instructor Notes (PPT Text) Check if the students are familiar with XAML. XAML files can become quite extensive. Briefly cover the code samples provided but do not go into too much detail at this stage. this technique produces a tighter coupling between UI and code. which detracts from the initial point. However. Explain that you use XAML to design the UI of a WPF or Silverlight application.

Module 12-Delivering Dynamic Content with Microsoft Silverlight página 246 .Creating Silverlight-Based Applications with Visual Studio 2008 Saturday.1 applications by using managed code and JScript. This lesson explains how to create a Silverlight application in Visual Studio and describes the content files in a Silverlight application. When you create a Silverlight application. It also explains how to create XAML objects and handle events in the code-behind file. September 06. Visual Studio creates a solution with a framework for the application. 2008 12:35 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Creating Silverlight-Based Applications with Visual Studio 2008 Visual Studio 2008 enables you to create Silverlight 1.

1 Refresh in this instance).com/fwlink/?LinkId=111452 Student Book Content Creating a Silverlight Application Key Points Visual Studio 2008 provides templates that you can use to create Silverlight applications and class libraries. Use the Add New Item dialog box to add a new Silverlight page to the application. and then install the templates (Microsoft Silverlight Tools Alpha for Visual Studio 2008 Beta 2 in this instance). September 06. Create a new Silverlight application by using Visual Studio 2008.Creating a Silverlight Application Saturday. Module 12-Delivering Dynamic Content with Microsoft Silverlight página 247 . First install the Silverlight runtime (Alpha 1. 2008 12:35 AM Instructor Notes (PPT Text) Use a demonstration to illustrate the key points of this topic. Reference: http://go. You can use the Silverlight Project template to create a Silverlight application or the Silverlight Class Library template to create a Silverlight class library. Explain that there are certain installation requirements before you can use Silverlight in Visual Studio.microsoft. Question: What types of files can you add to a Silverlight application? CD Content Visual Studio 2008 provides templates that you can use to create Silverlight applications.

xaml parameter in the createObjEx method that is used to instantiate the page.html. A TestPage. the solution contains: A Page. 2008 12:35 AM Instructor Notes (PPT Text) Use the Silverlight application that you created in the previous topic to discuss the initial files that Silverlight creates.js files at this point.html default file with an associated JScript file. A Silverlight.com/fwlink/?LinkId=111452 Student Book Content Content of a Silverlight Application Key Points When you create a Silverlight project in Visual Studio.xaml file for the UI with an associated source code file in Microsoft Visual C# ® or Microsoft Visual Basic ®. Avoid showing the content of the . Reference: http://go. Question: What do the JScript and XAML files contain? Module 12-Delivering Dynamic Content with Microsoft Silverlight página 248 . September 06. When you add more XAML pages to your application. Show all files in Solution Explorer so that the students can see the associated JScript file.Content of a Silverlight Application Saturday.microsoft.js file accordingly. Open this file and show the source Page. you must modify the TestPage.js file to create a Silverlight control in the Web page.

You can use a Canvas object as a drawing surface to contain other objects or embedded drawing surfaces.microsoft. Question: Can you nest Canvas objects to create a hierarchy of XAML objects? CD Content There are numerous object types that you can define in XAML and each has a specific use. Also mention empty elements.com/fwlink/?LinkId=111454 http://go. 2008 12:35 AM Instructor Notes (PPT Text) Mention that XAML objects define a hierarchical tree structure with a root object. XAML tags are similar to XML and HTML tags. for example. you can paste the example XAML code into the demonstration application.microsoft.Implementing XAML Objects Saturday. you use the following syntax. . Step through the samples provided in the CD content and ensure that the students understand the UI that is generated. References: http://go. To declare an object. Point out to the students that text must be in the form . Module 12-Delivering Dynamic Content with Microsoft Silverlight página 249 .com/fwlink/?LinkId=111455 Student Book Content Implementing XAML Objects Key Points You can define numerous objects in XAML. Each XAML object has a specific use.microsoft. Emphasize the reference to "Silverlight Overviews and How-to Topics" because it is a very good reference for extra information on the fundamentals of how to implement Silverlight objects.com/fwlink/?LinkId=111453 http://go. September 06. If you use a demonstration during this topic.

Explain that the code for the handler is compiled into a library and the library is then referenced from the XAML file. position. Module 12-Delivering Dynamic Content with Microsoft Silverlight página 250 . However. September 06.microsoft. many of which are optional. You can apply some general properties to many or all objects. mention that these options are beyond the scope of this course.com/fwlink/?LinkId=111456 Student Book Content You can also create a Polygon object and a Polyline object. These are most similar to the Path object. and in many situations you can use the Path object to create the same shape. This enables you to organize your application efficiently. Mention that it is also possible to write event handlers by using JScript or a dynamic language that targets managed code such as IronPython or managed JScript. and characteristics of an object. but the object will not render until you define some properties. so it is often useful to utilize the Canvas object to group other objects. point out the use of the x:Name attribute. Reference: http://go. Note: It is recommended that you open the Microsoft MSDN® page references that are provided in the CD content and have a quick look some of the details. However. which is critically important when you want to dynamically wire up event procedures by using code. see "Silverlight Overviews and How-to Topics" at http://go. some projects can become very complex. You can declare an object (such as a Rectangle).com/fwlink/?LinkId=110700 Object properties are important because they define the actual appearance.microsoft.Handling Events Saturday. 2008 12:35 AM Instructor Notes (PPT Text) If students are familiar with WPF then this process will not be new to them. There is no restriction to the number of objects that you can include in your Silverlight application. Each object type has a set of specific properties that you can use for that object. particularly properties that you use to position objects. Additional Reading: For more information about XAML objects. In particular.

right-click the Silverlight project. Note the following points: • Setting the ScaleY property of ScaleTransform to -1 flips (reflects) the video. . the MediaElement object determines the encoding and plays the media file with the appropriate codec. and then click Existing Item. double-click the Page. 6.microsoft. Point this out to the students. 2. 8. In Solution Explorer. Explain that the actual file extension of a media file is irrelevant. 12. View TestPage. September 06. select the video file. Mention that the MediaElement object supports many formats. Open the VideoTransform. Build the project.com/en-us/library/bb412386.html in a browser to watch the video. browse to the E:\Democode folder.xaml file.txt file. . View TestPage. In Solution Explorer.. in the Page.Demonstration . 2008 12:35 AM In this demonstration. In Visual Studio. Student Book Content Additional Reading: For more information about the x:Name attribute.. 6. 5. Add the following single line of code to the Canvas to create a MediaElement object that displays the video. The aim of the first three tasks of this demonstration is to show students how easy it is to incorporate video capability into a Silverlight application by using Visual Studio 2008. In the Add Existing Item dialog box. 3.wmv video file.MP3. Open Visual Studio 2008.xaml file. see the "x:Name Attribute" at Module 12-Delivering Dynamic Content with Microsoft Silverlight página 251 . students will see how use a Silverlight application to display a video file. You can extend this demonstration by creating video player controls for the Web page. for example.Displaying Video Files in a Silverlight Application Saturday. 10. see "Supported Media Formats and Protocols in Silverlight" at http://msdn2. 11. Create a project that uses the Silverlight Project template. The aim of the last task is to show students the rich media capabilities of a Silverlight application. 4.html in a browser to watch a skewed and reflected version of the video.aspx • Add a video file to a Silverlight application 1.txt file and copy its contents to the clipboard. and then click Add. Note: Do not watch the entire video when you view the transformations. Examine the code that you added. Background="White"> Instructor Notes (PPT Text) • Watch the video in a browser 7. For more information about the formats that the MediaElement object supports. • Perform transformations on the video 9. Build the project. Use Windows Explorer to browse to the E:\Democode folder. replace the line of code that you added in the second task with the code from the VideoTransform. • Add a MediaElement object to the Canvas 5. • Applying the OpacityMask on the MediaElement object creates the trailing transparency. point to Add.

Additional Reading: For more information about the x:Name attribute. see the "x:Name Attribute" at http://go.com/fwlink/?LinkId=110701 Module 12-Delivering Dynamic Content with Microsoft Silverlight página 252 .microsoft.

September 06. Remind the students to complete the discussion questions after the last lab exercise. click the link located at the bottom of the relevant lab exercise page. Module 12-Delivering Dynamic Content with Microsoft Silverlight página 253 . you will create a Silverlight project in Visual Studio and add some XAML objects to Page. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. you will investigate the features of Microsoft Silverlight and create a simple version of the Benefits Web site. you can demonstrate debugging in a Silverlight application by using the solution files. Before the students begin the lab. Exercise 1 In this exercise. To access the answer key. read the scenario associated with each exercise to the class. • Ensure students know how to access the Lab Answer Key so that they can successfully complete the required steps in the lab. In this lab. Point out that it is typically best practice to comment out code before you delete it because it can save you time and frustration later on. • If time permits. Instructor Notes (PPT Text) Student Book Content Lab: Delivering Dynamic Content with Microsoft Silverlight Exercise 1: Creating a Microsoft Silverlight-Based Application Scenario Coho Winery wants to upgrade its existing Benefits Web site to use richer and more dynamic content. Note: The lab exercise answer keys are provided on the Course Companion CD. The new Web site will contain a default page that loads an associated picture and dynamic text that explains each benefit when the user selects the benefit. 2008 12:35 AM In this lab.xaml to create a simple banner for the Web site. the students remove the code that they added in Exercise 1.Delivering Dynamic Content with Microsoft Silverlight Saturday. students create a new Microsoft Silverlight application. Important: Note the following points: • In Exercise 2. In this exercise. students will create a Microsoft Silverlight-based application that delivers dynamic content. Exercise 2 In this exercise. students add dynamic content to a Microsoft Silverlight application.Lab .

you can use (sender as Canvas). If the user clicked a button other than the active button. An integer named nextPage that contains the current page number. You can use the FindName method to concatenate the name of the selected button with the string _Click or _Leave to call the Begin method of the storyboards. Task 3: Create an event handler for when the user clicks a button 1. An integer named currentPage that contains the current page number. To find the name of the clicked button. Four images display a different benefit type and the other image displays a banner for the Web site. 2.Name (Visual C#) or TryCast(sender. create the following objects: A string named activeButton that contains the name of the currently selected button. 1 for Button1 and 2 for Button2. Student Book Content Task 2: Add images to the project and create variables 1. Add the images from the E:\Labfiles\Starter folder to the Benefits project. c) Check the name of the selected button. the following code inside an event procedure calls the Begin method of the clicked button. d) Set the activeButton string to the name of the selected button. Set this integer to 1. e) Call the Begin method of the Page_Out storyboard. and then in the Page class. perform the following: a) Call the Begin method of the buttonName_Click storyboard where the name of the button is the button selected. 2. September 06.Name (Visual Basic). There are five images in this folder. [Visual C#] Module 12-Delivering Dynamic Content with Microsoft Silverlight página 254 . and then set the nextPage integer accordingly. For example.Exercise 1 . b) Call the Begin method of the buttonName_Leave storyboard where the name of the button is the previously selected button. students will investigate the features of Microsoft Silverlight and create a simple version of the Benefits Web site. Canvas). The new Web site will contain a default page that loads an associated picture and dynamic text explaining each benefit when the user selects the benefit name. Open Page.Creating a Microsoft Silverlight-Based Application Saturday. create an event handler named OnMouseDown that accepts the event type MouseEventArgs. for example. Set this integer to 0.xaml. In the Page class. 2008 12:35 AM Instructor Notes (PPT Text) Coho Winery wants to upgrade its existing Benefits Web site to use richer and more dynamic content. In this lab.

or clicks one of the four buttons. click the buttons in the left pane to display a related picture and text. 4. you have added XAML code and images to display the front page of the Web site and event handling code to display an associated picture and text when the user selects a benefit. How can you easily add event procedures for many controls? You can use the FindName method in conjunction with a loop to concatenate the name of a control with a string such as "_Click". 2. This can create strings such as Button1_Click and Button2_Click that you can use to add event procedures. click Build Solution. and then click View in Browser.Exercise 2 . On the Build menu. There are elements for page fading and when the pointer enters. Close Internet Explorer. right-click TestPage. leaves. In the browser. September 06. Results:After this exercise. Module 12-Delivering Dynamic Content with Microsoft Silverlight página 255 . How can you create a circular XAML object? Use the Ellipse object. Student Book Content Task 8: Build and view the page 1. How can you create a square XAML object? Use the Rectangle object. 1. 2. 3. 4. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section.Adding Dynamic Content to a Microsoft Silverlight Application Saturday. 3.html. 2008 12:35 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. Where is the code for the object animation? The element contains elements for object animation. In Solution Explorer.

Module 13-Consuming and Creating XML Web Services página 256 . and each platform may run a different operating system. September 06. The problem with this is that the applications that you want to combine may be on a variety of platforms. or object models that they use. easy-to-use solution. standards-based model that you can use to connect applications together over the Internet. This lesson describes XML Web services and explains the process that you use to call an XML Web service from a Web Form. You often have to combine several applications into a single.Overview of XML Web Services Saturday. 2008 12:38 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Overview of XML Web Services One of the challenges that you may encounter when you create feature-rich Web sites is application integration. XML Web services provide a simple. The applications may also use several different programming languages. XML Web services enable you to take advantage of the existing Internet infrastructure and link applications regardless of which platforms. flexible. programming languages.

CD Content XML Web services are similar to components because they represent black-box functionality that developers can use to add features to a Web Form. you do not have to learn a new language every time you want to use an XML Web service. The XML Web services model assumes a stateless service architecture. XML Web services communicate by using standard Web protocols and data formats such as HTTP. such architectures are generally more scalable than statefull architectures.What Is an XML Web Service Saturday. Protocol Independence Module 13-Consuming and Creating XML Web Services página 257 . and Simple Object Access Protocol (SOAP).NET Framework-based language. As a result. Microsoft Windows ® Form. Application-to-Application Communication Across the Internet XML Web services interact directly with other applications over the Internet. September 06. 2008 12:38 AM Instructor Notes (PPT Text) Ensure that the students understand that XML Web services do not have a user interface (UI) but do use Internet-based protocols to communicate with other applications. XML Web services provide standard defined interfaces called contracts that describe the services that they provide. XML Web services do not have user interfaces (UIs). Language Independence You can write a connection to an XML Web service in any Microsoft . or even another XML Web service without worrying about how the supporting service is implemented. Student Book Content What Is an XML Web Service? Key Points XML Web services do not have a user interface (UI). XML. or it can be used externally by many applications that access it by using the Internet. Because of this flexibility. An XML Web service can be used internally by a single application. instead.

September 06. Question: What are some functions for XML Web services in your own applications? CD Content Module 13-Consuming and Creating XML Web Services página 258 . Visual Studio 2008 provides applications that make XML Web services extremely easy to develop and to consume. Ensure that the students understand the benefits of XML Web services.Why Use XML Web Services Saturday. 2008 12:38 AM Instructor Notes (PPT Text) The advantages of the XML Web service model may not be obvious to developers who do not have a lot of experience in connecting applications. Student Book Content Why Use XML Web Services? Key Points XML Web services enable you to share programming logic and capabilities with many other applications.

so the travel agency does not have to create or maintain dedicated connections to offer the service. Module 13-Consuming and Creating XML Web Services página 259 . If you have access to the Internet. this is a sophisticated travel Web site. A bank can access the customer base of multiple travel agencies. The travel agency does not bear the high maintenance costs of keeping data such as weather reports or exchange rates up-to-date. or subject expertise. From the user's perspective. 2008 12:38 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on this slide. September 06. and platform independent. by offering an application such as an exchange rate calculator as an XML Web service. so the travel agency developers do not have to learn how the XML Web service was built and deployed. This Web site provides advantages to both the travel agency and the various XML Web service providers: Advantages for the travel agency: The applications that the travel agency has access to are not limited by the travel agency developers' programming skills. In this scenario. availability. The steps that you use to create a proxy to consume an XML Web service will be explained in a later lesson. the Web site is a graphical interface that combines several XML Web services from unrelated companies.Finding an XML Web Service Saturday. Alternative delivery. Advantages for the XML Web service providers: The XML Web service provider may be able to charge the Web site for the use of the service. the user enters a destination city name.xml. find an XML Web service at the following Web sites: http://uddi. The XML Web services use the Internet. and the Web Form uses the city name as a parameter in calls to several XML Web services. The XML Web services are language.org/ Student Book Content Example of an XML Web Service A hypothetical travel Web site offers several features that are based on XML Web services. protocol. From a developer's perspective.

you will see how XML Web services interact with browsers and other Web Forms. September 06. XML Web Service Model A Web service consists of methods that are stored in an .asmx file. 2008 12:38 AM Instructor Notes (PPT Text) This multimedia explains how Web services interact with browsers and other Web Forms. Mention that to enable remote HTTP access to the XML Web service. the following elements must be included in the web. Module 13-Consuming and Creating XML Web Services página 260 .XML Web Service Execution Model Saturday.config file for the XML Web service: Student Book Content Multimedia: XML Web Service Execution Model Key Points In this animation. CD Content In this animation.Multimedia . you will see how XML Web services interact with browsers and other Web Forms.

Module 13-Consuming and Creating XML Web Services página 261 . and output of an XML Web service. you must create a proxy to handle the call. September 06. which is a process called direct access. 2008 12:38 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Calling an XML Web Service You can access an XML Web service directly from a browser by using HTTP. It also explains how to create a Web reference proxy for an XML Web service method and call the Web method from a Web Form.Calling an XML Web Service Saturday. properties. To accomplish this. This lesson describes how to access an XML Web service directly from a browser. Direct access enables you to view the methods. You can also call an XML Web service from a Web Form programmatically.

Open the demonstration Web service and show students how to browse to the XML Web service URL. you first access the HTML description page. 2008 12:38 AM Instructor Notes (PPT Text) Use a demonstration to illustrate the points as you discuss them. and the Web service responses. September 06.Calling an XML Web Service by Using HTTP Saturday. You can click a Web method to view the available parameters for that Web method and to test the method. Question: Why may you want to access a Web service by using HTTP? Module 13-Consuming and Creating XML Web Services página 262 . the Web method parameters. The description page provides information about what an XML Web service does. Student Book Content Calling an XML Web Service by Using HTTP Key Points When you access an XML Web service directly with a browser. the available Web methods that it contains. You can also append ?WSDL to the URL or click the service description link to show the WSDL document.

Also emphasize that this is the technique typically used to access the functionality of the Web service in a production application. Visual Studio 2008 automatically creates a proxy when you add a Web reference to an XML Web service. Module 13-Consuming and Creating XML Web Services página 263 . you must create a Web reference to the XML Web service in your Web application project. What Is a Proxy? A proxy class is code that looks exactly like the class it represents. however. The members in the generated proxy include: WebMethodName for synchronous communication. the SOAP call is managed internally and automatically. The proxy must be on the computer that has the Web application. Instead. Emphasize that the use of the proxy is the programmatic way to access Web services. Mention that when you invoke the Web service methods by using the proxy. WebMethodNameAsync to implement the event-driven asynchronous programming model. BeginWebMethodName to start asynchronous communication. A proxy object enables a client to access an XML Web service as if it is a local component. which is an XML protocol that you use to exchange structured and typed information. 2008 12:38 AM Instructor Notes (PPT Text) Explain that the Add Web Reference option creates the proxy automatically. it does not contain any of the application logic. EndWebMethodName to finish asynchronous communication.What Is a Proxy Saturday. Question: What is the purpose of the proxy class that is created when you create a Web reference to an XML Web service? CD Content To call an XML Web service from a Web Form. Student Book Content What Is a Proxy? Key Points To call an XML Web service. Interaction with SOAP Proxies and XML Web services interact by using SOAP. the proxy class contains marshaling and transport logic. The Web reference creates the proxy object that you use to communicate with the XML Web service by using SOAP. you create a Web reference to the XML Web service. September 06.

Additional Reading: For more information about calling an XML Web service asynchronously. several methods and properties that support programmatic access to the XML Web service are available. The Begin method is used to start asynchronous communication with an XML Web service method WebMethodName. and WebMethodNameAsync are automatically created in the proxy for every Web method of the XML Web service: WebMethodName. BeginWebMethodName.NET 2. 2008 12:38 AM Instructor Notes (PPT Text) This slide builds directly on the Finding an XML Web Service slide from the first lesson. The members that are available to a proxy include: Members built into the proxy.microsoft. Methods called WebMethodName. The Async method implements the event-driven asynchronous programming model. Emphasize to the students that they must create a reference to the Web service URL so that Microsoft Visual Studio can automatically create the proxy class. The WSDL file on the XML Web service server identifies the Web methods and parameters that are available in the XML Web service. September 06. The WebMethodName method of the proxy class is used to communicate with the Web service method synchronously. For example. Student Book Content Proxy Creation from the WSDL Document Visual Studio 2008 automatically creates a proxy when you create a new Web reference.0. "Overview of XML Web Services.com/fwlink/?LinkId=110703 WebMethodNameAsync.Steps for Calling an XML Web Service Saturday. you can return to the Finding an XML Web Service slide. which was introduced in ASP." To remind the students why they may want to build a proxy. EndWebMethodName. Proxy Members When you create a proxy by using Visual Studio 2008. Module 13-Consuming and Creating XML Web Services página 264 . EndWebMethodName. The End method is used to finish an asynchronous communication with an XML Web service method WebMethodName and retrieve the completed reply from the XML Web service method. see "Communicating With XML Web Services Asynchronously" at http://go. creating a Web reference to the Stocks XML Web service creates a proxy with two additional methods: BeginGetRating and EndGetRating. BeginWebMethodName. The infrastructure for making synchornous and asynchronous calls from a Web Form to an XML Web service is built into the proxy class that is created automatically by Visual Studio 2008 when you add a Web reference.

XML Web Service Error Handling Saturday. Explain that it is important to use structured error handling to test for these types of errors. 2008 12:38 AM Instructor Notes (PPT Text) Explain the possible error sources that students may encounter when they use a Web service. Long response delays. Student Book Content XML Web Service Error Handling Key Points The three major sources of error when you use an XML Web service are: Unavailable service. September 06. CD Content Module 13-Consuming and Creating XML Web Services página 265 . Errors that are internal to the XML Web service. Question: Discuss some occurrences that may cause an error when you access an XML Web service.

Catch statement around the call to the XML Web service. examine the Default. } } [Visual Basic] Protected Sub Button1_Click(ByVal sender As Object. examine the Service1 class.Service1(). ByVal e As System. EventArgs e) { WeatherWebRef.sln file from the E:\Democode\CS\WeatherSite or E:\Democode\VB\WeatherSite folder.Message End Try End Sub Module 13-Consuming and Creating XML Web Services página 266 . [Visual C#] protected void Button1_Click(object sender. 4.Click Dim getWeatherProxy As New WeatherWebRef. In the WeatherSite application.aspx Web page in the browser.Service1 getWeatherProxy = new WeatherWebRef. Add a try.catch to the Web service call 1. 2008 12:38 AM Instructor Notes (PPT Text) Use this demonstration to reinforce to students how important it is to handle errors when they access Web services.WeatherByCity(TextBox1.Timeout = 10000. Your code should resemble the following example.Service1 getWeatherProxy. The WeatherService Web service also opens. in the box on the page. getWeatherProxy.Demonstration . Open the WeatherSite... and then click Get Forecast.Text = getWeatherProxy. To run the demonstration 1. try { Label2. and then add code to add a Try. View the default. In this demonstration. In the WeatherSite application. modify the code to set a timeout of 10 seconds (10. 3.Testing the Availability of an XML Web Service Saturday.WeatherByCity(TextBox1. Repeat this step several times and then close the browser. students will see how to test if the XML Web service is available. type any city name.EventArgs) Handles Button1.000).. In the button event handler.Text) Catch err As Exception Label2.Text = err. add a Web Reference named WeatherWebRef that points to the WeatherService Web service.. 2.Text). } catch (Exception err) { Label2.Text = getWeatherProxy.Text = err. In the Web service.Timeout = 10000 Try Label2.aspx page.Message. September 06.

Student Book Content Demonstration: Testing the Availability of an XML Web Service In this demonstration. Module 13-Consuming and Creating XML Web Services página 267 . the instructor will show you how to test if the XML Web service is available.

2008 12:38 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Creating an XML Web Service Visual Studio 2008 provides templates that make it easy for you to develop XML Web services. This lesson describes how to use these templates to create an XML Web service. Module 13-Consuming and Creating XML Web Services página 268 .Creating an XML Web Service Saturday. September 06.

the code file is in the application root. 2. 2008 12:38 AM Instructor Notes (PPT Text) Student Book Content Steps to Create an XML Web Service Key Points When you create a new Web service application. Visual Studio 2008 creates a default Hello World function on the XML Web service page. You can use this function or write your own. and create a new ASP. Note: If you create a Web Service Web site. Module 13-Consuming and Creating XML Web Services página 269 . To create an XML Web service in Visual Studio 2008 1. Build the ASP. files. CD Content Visual Studio 2008 provides templates and a default XML Web service method to help you start to create XML Web services. right-click the XML Web service in Solution Explorer. It is recommended that you rename the project and the XML Web service to help you to identify and maintain the project and files. Visual Studio 2008 also creates a default Hello World function on the XML Web service page. You can write almost any kind of function as an XML Web service method from a simple local calculation to a complex database query. For a Web Service Application project.Steps to Create an XML Web Service Saturday. Declare the functions for the Web service. and then click View in Browser. 3.NET Web Service Web site. and the XML Web service page. Visual Studio 2008 automatically creates the required folders.NET Web Service Application project or an ASP. Each function must contain the [WebMethod] (Microsoft Visual C# ®) or <WebMethod()> (Microsoft Visual Basic ®) attribute. Visual Studio 2008 automatically creates the required folders. Open Visual Studio 2008. files. To test your Web service. the code file that supports the logic of the Web service is placed in the App_Code folder. and the XML Web service page.NET Web Service project. September 06.

Student Book Content XML Web Service Code Key Points Web services consist of two primary files.asmx file identifies the Web page as an XML Web service.asmx.asmx file identifies the Web page as an XML Web service.cs or .XML Web Service Code Saturday. The .vb file contains the XML Web service logic. CD Content When you create an XML Web service with Visual Studio 2008.asmx. Module 13-Consuming and Creating XML Web Services página 270 . September 06. use a demonstration to illustrate how to create a Web service. 2008 12:38 AM Instructor Notes (PPT Text) If you have time.cs or . The .vb file. two primary files are created that make up the XML Web service: the .asmx. and the code file contains the XML Web service logic.asmx file and the .asmx. and the .

Alternative delivery. ' <System. You can edit the default function or add your own functions.Web.Services.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class Service1 Inherits System. September 06.Web.Web.Services Imports System.Web. data types.ScriptService()> _ <System.Web. You must flag each method that you want to expose from the XML Web service with a custom [WebMethod] (Visual C#) or <WebMethod()> (Visual Basic) attribute.NET ' AJAX. This namespace contains the methods and properties that support XML Web services. All of the Web methods. uncomment the following line.Services. [Visual C#] Module 13-Consuming and Creating XML Web Services página 271 . XML Web service methods.Services. Visual Studio 2008 creates a default Hello World Web method.Consuming and Creating XML Web Services Saturday. Class.Services. using ASP. This attribute is required because without it. and the Web service itself inherit the namespace.WebService <WebMethod()> _ Public Function HelloWorld() As String Return "Hello World" End Function End Class Code-behind pages have the following attributes: Namespaces. The following example displays the code for the default Visual Studio 2008 XML Web service method.Protocols Imports System.Services namespace.Web. the XML Web service can be a wrapper for almost any application on any platform. 2008 12:38 AM Instructor Notes (PPT Text) The key point is that although the code that creates the XML Web service is constant.Script.Services. Use a demonstration to illustrate the points in this topic. The default XML Web service class is Service1.org/")> _ <System. the method is not exposed from the XML Web service. XML Web services import several namespaces. Student Book Content [Visual Basic] Imports System.WebServiceBinding _ (ConformsTo:=WsiProfiles.Web.Lab .WebService(Namespace:="http://tempuri.ComponentModel ' To allow this Web Service to be called from script. including the System. The Class attribute identifies the base class that supports this instance of an XML Web service.

dll file that targets the official release of . Remind the students to complete the discussion questions after the last lab exercise. To access the answer key. click the link located at the bottom of the relevant lab exercise page. students will create and test an XML Web service.Exercise 1 . read the scenario associated with each exercise to the class.codeplex. a warning message appears because the AjaxControlToolkit. students consume the GetDentistsByPostalCode Web method. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. Exercise 4 In this exercise. students create a Web method that returns a DataSet by using a stored procedure.5 and Visual Studio 2008 from the www. Note: The lab exercise answer keys are provided on the Course Companion CD. September 06.dll file.NET Framework 3. Note: When you run the application. Exercise 2 In this exercise. You can ignore this warning message or download the version of the AjaxControlToolkit. you have consumed the GetDentistsByPostalCode XML Web Service method.com Web site.Creating the Dentist XML Web Service and the GetAllDentists XML Web Service Method Saturday. Student Book Content Results: After this exercise. copy it to the virtual machine to remove the warning message. Exercise 1 In this exercise. Exercise 3 In this exercise. 2008 12:38 AM Instructor Notes (PPT Text) In this lab. Before the students begin the lab.dll file is not present in the virtual machine. Mention this to the students. Module 13-Consuming and Creating XML Web Services página 272 . If you download the AjaxControlToolkit. students consume the GetAllDentists Web method. students create an XML Web service that contains a Web method that returns a DataSet from a Microsoft SQL Server™ database.

Creating the GetDentistsByPostalCode XML Web Service Method Saturday. September 06. the function will not be exposed on the Web. The Web service will contain two Web methods: one that retrieves all of the dentists from the dentists table and one that uses a stored procedure to retrieve the dentists for a specific postal code. Module 13-Consuming and Creating XML Web Services página 273 . 5.Exercise 2 . Students will then call the stored procedures from a Web Form. students will create an XML Web service that retrieves data from the dentists database. Student Book Content You set a timeout for the proxy and look for timeout exceptions when you call the Web methods of the XML Web service. Without it. What attribute do you add to methods that you want to be exposed to the Web from your XML Web service? WebMethod is required. 2008 12:38 AM Instructor Notes (PPT Text) In this lab.

Student Book Content Module 13-Consuming and Creating XML Web Services página 274 .Consuming the GetAllDentists XML Web Service Method Saturday. What must you do in the Benefits Web site before you can consume the methods in the DentalService Web service? Add a Web reference to the Web service. When you test a Web service. 1.Exercise 3 . where does the description page come from? This page is automatically created by ASP. 2008 12:38 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. What is the effect if you change the default namespace of a Web service? The warning message no longer appears in the service description page. 3. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. September 06. 2.NET from the XML Web service description.

you should provide some high-level hints that might help the students solve the problem stated in the scenarios. If you assign the scenarios as homework. Instructor Notes (PPT Text) Student Book Content Module 13-Consuming and Creating XML Web Services página 275 .Exercise 4 . You can also do a follow-up debriefing the following day on some of the scenarios that have been assigned as homework to students. Real-World Issues and Scenarios You can either discuss possible solutions for the scenarios at the end of the module or assign these scenarios as homework for the students. and Integration (UDDI) Web site ○ Discovery file (DISCO) documents: . as follows: ○ Universal Description. How can you do this? Use one or more of a series of discovery services. 2008 12:38 AM Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section.Consuming the GetDentistsByPostalCode XML Web Service Method Saturday.disco. Discovery. You can create high-level hints for each scenario by using the following possible solutions for the scenarios. . September 06. • You need to find existing XML Web services to add to your Web site. Common Issues and Troubleshooting Tips Point the students to possible troubleshooting tips for the issues presented in this section.vsdisco ○ Web Services Description Language (WSDL) files • How can you add information to a Web service? When you create a Web service and add methods to it. you can add information to the service in the form of attributes.

Module 14-Managing State página 276 . 2008 12:40 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 State Management The connection that is established between a user (the client computer) and a Web server is called a session. you will begin to understand in detail what state management is and why it is important to manage state. Sessions can span multiple Web pages and are tracked by using state management. In this lesson.State Management Saturday. September 06. This lesson explains server-side state management and client-side state management and describes the Global.asax file. State management is the process by which you maintain the same information throughout multiple requests for the same or different Web pages.

Student Book Content What Is State Management? Key Points ASP. 2008 12:40 AM Instructor Notes (PPT Text) Ensure that the students understand that HTTP is a stateless protocol but Microsoft® ASP. September 06. This is particularly useful during the postback process when a user fills out a long or complicated form. this helps to maintain the continuity of user information (state) throughout a visit to a Web site. you can reuse the information so that users do not have to reenter the same information multiple times. what happens to user details after they are provided by a user on an initial logon page? Module 14-Managing State página 277 .What Is State Management Saturday.NET provides state management to enable you to store and retrieve user information. Question: If you do not use state management.NET provides state management that saves information on the server between page requests and postbacks. If state is maintained between pages.

September 06. the second page welcomes the user by his name. Question: What are the differences between server-side and client-side state management? Module 14-Managing State página 278 .Types of State Management Saturday.NET provides two types of state management: Server-side state management options use server resources to store state information. Control state stores the data of a control (for example. These options provide higher security than client-side state management. Do not spend too much time on the ViewState property and query strings. Types of State Management Key Points ASP. However. session state. State management is scalable Mention that because the Microsoft SQL Server™ database or state server do not have to be on the same server as the Web application. and cookies. when the user's personal information is sent to the server. Control state is similar to view state but functionally independent of view state. Therefore. you can use state management in your Web application to maintain state across multiple Web pages. 2008 12:40 AM Instructor Notes (PPT Text) The focus of this module is application state. a page number) that must be available on postback to enable the control to function even when view state is disabled. it allows for a more scalable approach to state management. it can be unreliable and pose a security risk if you want to store sensitive information. Student Book Content However. Mention that cookies have security implications because information is stored in plain text. Client-side state management does not use server resources to store state information and therefore offers fast server performance.

September 06. Mention that the SessionID for a page request appeared on the trace ouput page shown in Module 5.Server-Side State Management Saturday." Student Book Content Server-Side State Management Key Points Application state is a global storage mechanism that is accessible from all of the pages in the Web application. Question: How does ASP. If multiple users access a Web application. "Tracing and Debugging. 2008 12:40 AM Instructor Notes (PPT Text) Ensure that students understand the difference between application and session state. It enables you to store user information between server round trips and between pages. Session state is similar to application state except that it is limited to the current browser session. each user has a different session state.NET provide application state and session state? Module 14-Managing State página 279 .

A cookie contains page-specific information that is stored either in a text file on the file system of the client computer or in-memory in the client-browser session. 2008 12:40 AM Instructor Notes (PPT Text) Explain the key features of cookies. Also explain why they are not as useful as server side state management. Question: Why are cookies less secure than server-side state management options? CD Content Most Web applications use cookies for client-side state management. Cookies are not as secure as server-side state management options. Cookies can expire when the browser session ends or they can exist indefinitely on the client computer.Client-Side State Management Saturday. Mention that persistent cookies have an expiration time. September 06. Module 14-Managing State página 280 . Student Book Content Client-Side State Management Key Points Most Web applications use cookies for client-side state management.

Every ASP.asax file is stored in the virtual root of the Web application. the Global. 2008 12:40 AM Emphasize that this file is optional.asax file is an optional declarative file that you can use to handle events while your Web application is running. • Conditional application events.asax File Saturday.The Global. Mention that there are three categories of events that are supported by Global. • Events that are fired when the requested page is sent. Mention a few of the events from each category. Question: What are the types of events that the Global. Module 14-Managing State página 281 . September 06.asax file supports? CD Content The Global. Instructor Notes (PPT Text) Student Book Content The Global.NET Web application supports one Global.asax: • Events that are fired when a page is requested.asax File Key Points The Global.asax file is a declarative file that you can use to handle events while your Web application is running.asax file per Web application.

Application and Session Variables Saturday. 2008 12:40 AM Instructor Notes (PPT Text) Student Book Content Module 14-Managing State página 282 . September 06.

Initializing Application and Session Variables
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Mention that you initialize session and application variables in the Global.asax file, in the Start event procedures of the Application and Session objects.

Student Book Content
Lesson 2

Application and Session Variables
You can use application and session variables to share information between the pages of an ASP.NET Web application. This lesson explains how to initialize and use application and session variables. It also demonstrates how to specify the duration for application and session variables and describes how application and session variables impact scalable storage. Finally, it explains how to save application and session variables in a database.

Module 14-Managing State página 283

Accessing Application and Session Variables
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Ask students why they must use Application.Loc k and Application.UnLoc k when they access application and session variables. Mention that when you increment application and session variables, you can use "+=" in Microsoft Visual Basic® but not in Microsoft Visual C#®. Emphasize that the read value from the application and session variables must be explicitly cast to the correct data type. In Visual Basic, this is necessary when Option Strict is On.

Student Book Content

Accessing Application and Session Variables
Key Points
To set a session variable, you must provide a key that identifies the item that you want to store. You must also set a value. To set an application variable, you must prevent multiple users or applications from updating the data simultaneously by using a simple set of locking methods. To use a session or application variable in an ASP.NET page, you can read the value from the Session or Application object. Question: When you set application variables, why must you use the locking methods of the Application object?

Module 14-Managing State página 284

Application and Session Variable Duration
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Explain that a shorter session duration uses fewer resources on the Web server.

Student Book Content

Application and Session Variable Duration
Key Points
By default, a session times out when a user has not requested a page for more than 20 minutes. If the same user requests a page after 20 minutes, that user is treated as a new user. You can modify the session duration in the web.config file. Question: What must you set in the web.config file to modify the session duration?

CD Content
HTTP is a stateless protocol. A Web server has no means of detecting when a user leaves a Web site. Instead, the Web server detects that a certain period of time has passed without the user requesting a page. At that point, the Web server removes all of the items in session state that are associated with that user.

Module 14-Managing State página 285

Scalable Storage of Application and Session Variables
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Mention that it is also possible to create a custom session-state store provider if required.

Student Book Content

Scalable Storage of Application and Session Variables
Key Points
By default, session state is managed in-process so all of the information that is added to a session state is stored in the same Web server that runs the ASP.NET Web application. However, this limits the scalability of your Web site. You can store session state out-of-process by managing session state with a Microsoft SQL Server™ database or a separate state server. To store session state out-of-process, you must modify the Web.config file to set the sessionState element. The main advantage of out of process management is that is provides scalability for your Web site. Question: If you want to store session state out of process, what values must you set for the sessionState element?

Module 14-Managing State página 286

Saving Application and Session Variables in a Database
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Explain that the Aspnet_regsql.exe tool creates a database named ASPState that contains stored procedures that support SQLServer mode. The session data is stored in the TempDB database by default. You can use the -sstype option to store the data in a specified database. Demonstrate the Aspnet_regsql tool by typing the following command at a command prompt. aspnet_regsql -ssadd -S LON-DEV\sqlexpress -E -sstype p

Student Book Content

Saving Application and Session Variables in a Database
Key Points
To save application and session variables in a SQL Server database or in a state server: 1. Configure the session state in the Web.config file of your Web server. 2. Configure the SQL Server database or the state server.

Question: What must you modify in the Web.config file to configure the session state?

Module 14-Managing State página 287

Cookies and Cookieless Sessions
Saturday, September 06, 2008 12:40 AM

Instructor Notes (PPT Text)

Student Book Content
Lesson 3

Cookies and Cookieless Sessions
Cookies are a means by which the Web application that runs on the Web server can cause a client to return information to the Web server with each HTTP request. You can use the returned information to maintain state with the client across multiple requests. Cookies are sent to the client as part of the Hypertext Transfer Protocol (HTTP) header in a client request or are sent in a server response. This lesson explains how to use cookies to store session data and how to retrieve that data from a cookie. It also describes cookieless sessions and explains how to set up cookieless sessions.

Module 14-Managing State página 288

The Cookies property represents a collection of cookies and is an instance of the HttpCookieCollection class. September 06. Point out that the response is a write action and the request is a read action.Storing Session Date by Using Cookies Saturday. 2008 12:40 AM Instructor Notes (PPT Text) This slide shows the code that creates a temporary (non-persistent) cookie. This is how the cookie crumbles. Question: How do you set the expiration time of a cookie? Module 14-Managing State página 289 . Mention that if you create a cookie that already exists. The cookie contains information about the domain. Persistent cookies are saved as text files to the hard disk. the cookie changes from a temporary cookie to a persistent cookie. The line of code that is added to the slide sets the expiration time to create a persistent cookie. the old cookie is destroyed. Display the cookies folder on the file system to the students and examine the format of file which contains the domain name. If you set the expiration time of a cookie. Student Book Content Storing Session Date by Using Cookies Key Points You can create cookies by using the Cookies collection of the Response and Request objects.

FromName Method" at http://msdn2.FromName method.color. A cookie is returned to the server by the client in an HTTP "Cookie:" header. September 06. Student Book Content Retrieving Information from a Cookie Key Points To retrieve information from a cookie. 2008 12:40 AM Instructor Notes (PPT Text) Step through the code and ensure that the students understand how to retrieve the key and value pairs from the cookie. Multiple cookies.fromname. Module 14-Managing State página 290 . separated by semicolons.draw ing.Retrieving Information from a Cookie Saturday.aspx Also. If you attempt to read a cookie that does not exist (such as a cookie that has been deleted by a user). you read the cookie and retrieve the key/value pairs from the cookie. point out that some data type conversion may be necessary when you read the values from a cookie. CD Content To retrieve information from a cookie. You can read an existing cookie by accessing the Cookies collection of the Request object. It is always good practice to check for a null value first. For more information about the Color.microsoft.com/en-us/library/system. can appear in this header. you read the cookie and retrieve the key/value pairs from the cookie. see "Color. you can potentially receive a null reference exception.

Module 14-Managing State página 291 . Question: What are the limitations of cookieless sessions? CD Content Each active session is identified and tracked by using a SessionID.Cookieless Sessions Saturday. Student Book Content Cookieless Sessions Key Points Cookieless sessions enable you to take advantage of session state even with browsers that have cookie support disabled. SessionID is stored in cookies. By default. The process of including the SessionID in the URL is known as URL munging. 2008 12:40 AM Instructor Notes (PPT Text) Ensure that the students understand that cookieless sessions can be used only in limited circumstances. The SessionID is communicated across clientserver requests by using an HTTP cookie or by including it in the URL. This has several implications because of the limitations URL characters and mobile devices. The SessionID that identifies the active session is included in the URL instead of a cookie. September 06.

set the cookieless attribute to the value true.config file are generally referred to in camelCase. 2008 12:40 AM Instructor Notes (PPT Text) Mention that the sections in the web. Setting up a Cookieless Session In the Web. CD Content You enable cookieless sessions by modifying a single attribute in the Web. in the <sessionState> section of the Web. The following code example illustrates this. You only have to set this value to enable cookieless sessions. in the <sessionState>section.config file. <sessionState cookieless="true" /> Module 14-Managing State página 292 .config file. Student Book Content Setting Up Cookieless Sessions Key Points To enable cookieless sessions.Setting Up Cookieless Sessions Saturday.config file. September 06. set the cookieless attribute to true.

In the current Web site. students will store application and session data. students create session and application variables and then use them to store and retrieve information. If you download the AjaxControlToolkit. Exercise 3 In this exercise. and write from persistent cookies. Mention this to the students. In this lab. users must enter redundant information on multiple pages. You can ignore this warning message or download the version of the AjaxControlToolkit. Remind the students to complete the discussion questions after the last lab exercise. Before the students begin the lab. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. copy it to the virtual machine to remove the warning message. To simplify the user experience of the Web site.NET Framework 3.dll file that targets the official release of . click the link located at the bottom of the relevant lab exercise page. Exercise 4 In this exercise.com Web site. Note: When you run the application. 2008 12:40 AM Instructor Notes (PPT Text) In this lab. Exercise 2 In this exercise. read the scenario associated with each exercise to the class. Exercise 1 In this exercise. you will create a Web site that enables employees to select and set up their chosen benefits.dll file is not present in the virtual machine. Note: The lab exercise answer keys are provided on the Course Companion CD. students store session variables in a Microsoft SQL Server database. read to. users must supply their name and birth date on both the medical page and the life insurance page. To access the answer key.codeplex. September 06. you will use a cookie to store this information in session variables so that users must enter this information only once. students create a page counter by using an application variable.5 and Visual Studio 2008 from the www. Student Book Content Lab: Storing Application and Session Data Exercise 1: Implementing Session Variables Scenario Coho Winery offers several benefits to its employees.Lab . students create.dll file. For example. a warning message appears because the AjaxControlToolkit. Module 14-Managing State página 293 .Storing Application and Session Data Saturday. In the labs for this course. you will use session and application variables to enhance the experience for users when they browse the Benefits Web site.

The browser returns you to the Default. In the browser. students will use session and application variables to enhance the experience for users when they browse the Benefits Web site. 3. 2. the page now contains the life insurance information. users must enter redundant information on multiple pages. 6. select one or both of the term coverage options. In Solution Explorer. click the Medical link. and then click Save. Select a doctor.aspx page. 5.Implementing Session Variables Saturday. Student Book Content Task 4: Test the cookie 1. users must supply their name and birth date on both the medical page and the life insurance page. and then click View in Browser. In the browser. right-click Default. the page now contains the doctor information. and then click Save.Exercise 1 . Fill in the required information. To simplify the user experience of the Web site. click the Life Insurance link. 2008 12:40 AM Instructor Notes (PPT Text) In this lab. The browser returns you to the Default. Results:After this exercise. you have used cookies to store all of a user's benefits selections and when a user returns to the Default. For example. Close the browser. students will use a cookie to store this information in session variables so that users must enter this information only once. the page lists the selected benefits for the user.aspx.aspx page. In the current Web application. Module 14-Managing State página 294 .aspx page. September 06. 4.

[Visual Basic] Session("VariableName") = "Value" 2. 3. 3. How can you store the session variables in a SQL Server database? In the web.Implementing Cookies Saturday. When you modify an application variable. How do you set up a Web application to use cookieless sessions? Create a <sessionState> section in the Web. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. Can there be more than one Global.Exercise 2 . September 06. why must you lock it? If you do not lock an application variable. multiple clients can simultaneously attempt to modify it.config file and set the cookieless attribute to true.config file. set the Mode. Where can you initialize application variables? It is advisable to create and initialize application variables in the Application_Start event of the Global. create a sessionState child element. and conditional application events. What are the three categories of events that are handled in the Global. where VariableName is the name of the session variable and Value is the value of the session variable.Cookies. 1. 4. cookieless. 4. sqlConnectionString. events that are fired when the requested page is sent. Module 14-Managing State página 295 . 2008 12:40 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. and Timeout attributes accordingly.asax file? Events that are fired when a page is requested.asax file.asax file if the application contains ASP pages. but you can also have a Global.Cookies. In the sessionState element. [Visual C#] Session["VariableName"] = "Value". Pass the name of the cookie as a parameter to Request. How can you check if a cookie exists? To check if a cookie exists.asax file for a single Web application? No. If the HttpCookie instance is null. Why must you initialize application variables? You must initialize application variables because they can produce a null reference exception. the cookie does not exist. first create a HttpCookie instance by calling Request. 5. in the system.web element. How do you set session variables? The following syntax sets a session variable. <sessionState cookieless="true"/> 2. Student Book Content CD Content Review Questions 1.

Best Practices Help the students understand the best practices presented in this section. Ask students to consider these best practices in the context of their own business situations. Let students review the function and usage of each tool on their own. Student Book Content Module 14-Managing State página 296 . Tools Point out the location from which each key tool can be installed. Remind students that they can use this as a master list to help them gather all the tools required to facilitate their application support work. September 06. 2008 12:40 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section.Exercise 3 .Implementing Application Variables Saturday.

Exercise 4 . September 06.Storing Session Variables in a Database Saturday. 2008 12:40 AM Student Book Content Module 14-Managing State página 297 .

NET Web Application página 298 . Module 15-Configuring. This lesson describes how to set up the Cache object to optimize the response times for a Web application.NET Web application is to use the ASP.Implementing the Cache Object Saturday. Optimizing. September 06. and Deploying a Microsoft ASP. 2008 12:42 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Implementing the Cache Object One of most effective ways to increase the performance of an ASP.NET Cache object. The Cache object enables you to place items in server memory so that you can quickly retrieve them.

ASP. particularly information that demands significant processor time on the server every time that it is created.NET checks the Cache object and uses the cached version if it is available. Module 15-Configuring. Storing Information ASP. you do not have to recreate information that satisfied a previous request.NET Web Application página 299 . therefore. The Cache object merely holds a reference to those objects and provides a process to track their dependencies and set expiration policies. September 06. In addition to caching individual items such as computational results in the Cache object. The cache methods implement automatic locking. Question: What are some possible uses for the Cache object in your own applications? CD Content An issue that you will encounter when you build high-performance Web applications is the requirement to avoid duplication. The Cache object has no information about the content of the items it contains. 2008 12:42 AM Instructor Notes (PPT Text) Check to see how familiar the students are with the Cache object. and may require code to cast to the appropriate data type on retrieval.NET provides a full-featured cache engine that you use to store and retrieve information. By using the cached copy.NET recreates the item. The Cache object also provides a method to pass values between pages in the same Web application. Ensure that the students understand the difference between the Cache object and page output caching. uses that item. and then stores that item in the Cache object for future use. 2. ASP.What Is the Cache Object Saturday. You may be able to skim through this topic. If a cached version is not available. and Deploying a Microsoft ASP. Student Book Content What Is the Cache Object? Key Points The following process describes how the Cache object works: 1. ASP. Mention that an object stored in the cache is just that. Optimizing. it is safe for the application to access values concurrently from more than one page. The Cache object and the output cache are distinct objects with unique roles and properties. A Cache object enables you to store items in memory the first time that they are requested and then use the cached copy for later requests.NET offers an output cache that you can use to store Web pages and user controls. A page requests an item that is stored in the Cache object. an object.

[Visual Basic] myValue = Cache("myKey") Additional Reading: For more information on caching. Student Book Content [Visual Basic] Cache("mykey") = myValue To retrieve an item from a Cache object.microsoft.NET Web Application página 300 . [Visual C#] myValue = Cache["myKey"].com/fwlink/?LinkId=110706 Module 15-Configuring. http://go. use the following code. see "Caching Application Data". and Deploying a Microsoft ASP.Advantages of the Cache Object Saturday. Optimizing. September 06. 2008 12:42 AM Instructor Notes (PPT Text) Explain the advantages of the Cache object to the students.

September 06. The key is the Cache key string that you use to reference the item. you provide the correct key to hold the retrieved value and cast the object to the correct data type. 2008 12:42 AM Instructor Notes (PPT Text) Explain to the students the two methods that you can use to write to the Cache object: implicit and explicit.How to Use the Cache Object Saturday. Optimizing. you use key-value pairs to store and retrieve items.NET Web Application página 301 . and Deploying a Microsoft ASP. Student Book Content How to Use the Cache Object Key Points You can write an item into a Cache object implicitly or you can use the explicit Insert method with parameters. CD Content To use the Cache object. To retrieve a value from the cache. Module 15-Configuring. The value is the item that you want to cache.

Insert("MyBook.Now.CurrentBook". [Visual Basic] Cache. _ TimeSpan. new CacheDependency _ (Server.MapPath("Books. TimeSpan. dependencies.Removing Items from the Cache Object Saturday. DateTime.CurrentBook". CurrentBook. September 06. CurrentBook.FromSeconds(30). and priorities for items.AddMinutes(5). new CacheDependency (Server. CacheItemPriority. DateTime. Optimizing.xml")).xml")). and Deploying a Microsoft ASP. CacheItemPriority.NET Web Application página 302 .FromSeconds(30). Student Book Content Removing Items from the Cache Object Key Points To influence how the Cache object saves and removes items.High.MapPath("Books. as shown in the following code example: [Visual C#] Cache.Now. onRemove) Module 15-Configuring.Insert("MyBook. define time limits. Also explain that it is possible to influence how these items are removed.High. 2008 12:42 AM Instructor Notes (PPT Text) Explain that the Cache object automatically removes the least used items when memory becomes scarce.AddMinutes(5). onRemove).

_ Nothing. 2008 12:42 AM Instructor Notes (PPT Text) Student Book Content [Visual Basic] Cache. If a dependency changes. [Visual Basic] Module 15-Configuring. September 06.Insert("myKey". Items that you assign higher priority values to are less likely to be removed from the cache.xml file changes.ASP. myValue. myValue.Insert("myKey".MapPath("myDoc.NET Output Caching Saturday.Insert("myKey". _ new CacheDependency(Server. whereas the items to which you assign lower priority values are more likely to be removed.Insert("myKey". [Visual Basic] Cache. Dependencies based on external files and directories are referred to as file dependencies.xml"))). Nothing. [Visual C#] Cache. [Visual C#] Cache. dependencies based on another cached item are referred to as key dependencies.NET Web Application página 303 . The following code specifies that myValue has a high priority. the Cache object selectively removes items to free up system memory. null.NoSlidingExpiration.NET enables you to define the validity of a cached item based on file dependencies or another cached item. Optimizing. TimeSpan. and Deploying a Microsoft ASP.MapPath("myDoc. The following code example removes myValue from the Cache object when the myDoc. new CacheDependency(Server. null.FromSeconds(20)) Dependencies There are times when you want to remove an object from the Cache object because a related item such as a file has changed. ASP.High).xml"))) Cache Item Priority When the Web server runs low on memory.NET invalidates the cached item and removes it from the Cache object. ASP. myValue. myValue. CacheItemPriority. Cache.

and Deploying a Microsoft ASP. you will see how the page output cache affects server response times when an ASP.Output Caching Saturday. Module 15-Configuring.Multimedia . September 06. Student Book Content Multimedia: Output Caching In this animation.NET Web Application página 304 . 2008 12:42 AM Instructor Notes (PPT Text) If necessary. discuss the multimedia after you have viewed it. Optimizing.NET Web Form is requested more than once.

2008 12:42 AM Instructor Notes (PPT Text) Do not spend more than the allotted time on page caching and page fragment caching. You can cache portions of a page by creating the section as a user control and then caching the user control with the page output cache. For a Web service. these topics will be explained in more depth later in this lesson.Output Cache Types Saturday. Student Book Content Output Cache Types Key Points Page output caching enables you to store entire Web Forms and user controls in server memory. September 06. and Deploying a Microsoft ASP. Optimizing. you can specify the number of seconds that the results for the XML Web service method will remain in the output cache. Question: How can your own applications benefit from page output caching? CD Content Module 15-Configuring.NET Web Application página 305 .

and Deploying a Microsoft ASP. 2008 12:42 AM Instructor Notes (PPT Text) Ensure that the students understand that c aching provides a powerful way to improve the performance of a Web application. September 06.Implementing the Page Output Cache Saturday. Optimizing. Student Book Content Implementing the Page Output Cache Key Points You can implement the page output cache: Declaratively by using the @ OutputCache directive. Programmatically by using the SetCacheabilitymethod on the Cache property of the Response object.NET Web Application página 306 . In a configuration file by using the OutputCache and OutputCacheSettings elements. CD Content Module 15-Configuring.

September 06. and Deploying a Microsoft ASP. Student Book Content Implementing Control Caching Key Points Control caching enables you to separate certain portions of a page from the rest of the page. CD Content Module 15-Configuring. and lists that are used by multiple pages. You can set the caching policies for a user control declaratively by using the @ OutputCache directive or programmatically by using the PartialCachingAttribute class. 2008 12:42 AM Instructor Notes (PPT Text) Explain that control caching enables you to separate portions of a page that take valuable processor time to create (such as database queries) from other parts of the page. Items that are good candidates for control caching include headers.Implementing Control Caching Saturday.NET Web Application página 307 . footers. Optimizing.

. End Class Post-Cache Substitution Post-cache substitution enables you to cache a Web page but enable sections of the page to remain dynamic.com/fwlink/?LinkId=110710 Module 15-Configuring. Optimizing. 2008 12:42 AM Instructor Notes (PPT Text) Student Book Content [Visual Basic] <PartialCaching(25)> _ Partial Class myControl Inherits UserControl .NET Web Application página 308 . Additional Reading: For more information about post-cache substitution.NET Web Application Saturday. You specify that areas of a page cannot be placed in the cache by using the Substitution or AdRotator controls. and Deploying a Microsoft ASP..Configuring an ASP. September 06. see "Dynamically Updating Portions of a Cached Page" at http://go. These areas of the page are then created dynamically at each page request and combined with the cached page output.microsoft.

config file and point out inherited and overridden settings.NET Web Application página 309 . and Deploying a Microsoft ASP. Mention that it is important that the config files contain well-formed XML because a malformed file causes the Web site to crash.config files does your application use? CD Content Configuration information for ASP. Optimizing. Module 15-Configuring. Each configuration file contains a nested hierarchy of XML elements with attributes that specify the configuration settings.Overview of Configuration Files Saturday. Student Book Content Overview of Configuration Files Key Points Configuration information for ASP. September 06. you can open the Machine.NET resources is contained in a collection of configuration files. Each configuration file contains a nested hierarchy of XML elements with attributes that specify the configuration settings. Question: How many web.NET resources is contained in a collection of configuration files.config file and a web. 2008 12:42 AM Instructor Notes (PPT Text) If time permits.

it inherits the settings in the web.NET Web Application página 310 . This file in turn inherits settings from the Machine. Tag names and attribute names are camelCased.config file. As a result.config file in the application root folder. All configuration information in a . Module 15-Configuring.config file in the config folder of the installed framework on the server.config file resides between the <configuration> and </configuration> root XML tags.config file to store settings that apply to all of the ASP.config files. Explain the advantages and disadvantages of storing configuration settings in the Machine.NET Web applications that reside on that Web server. 2008 12:42 AM Instructor Notes (PPT Text) Mention that the Machine.config Machine-level configuration settings are stored in the Machine. Student Book Content Machine.config file.config file stores the default settings for an entire computer.config files must be well-formed XML. you can use the Machine. and Deploying a Microsoft ASP.config and web.config file. Optimizing. Virtual directories can have their own web. There is only one Machine. If a web application does not have a web. Each Web application typically has at least one web. the elements and attributes are case sensitive.config files that contain settings that are specific to that directory. Web.Configuring a Web Server by Using Machine.config Application and directory-level settings are stored in web. which means that the first character of a tag name is lowercase and the first letter of any subsequent concatenated words is uppercase.config file.config file Attributes Because the tags in Machine. September 06.config Saturday. .config file on each Web server.

and Deploying a Microsoft ASP. Optimizing.NET Web Application página 311 . A single web. CD Content In ASP.config files.NET. Module 15-Configuring. You can place additional web.config Key Points You use the web. September 06.config file is typically located in the root folder of the Web application.config Saturday. 2008 12:42 AM Instructor Notes (PPT Text) Ensure that the students are familiar with the purpose of web.config files in the folder of the virtual directory to which they belong. Student Book Content Configuring an Application by Using Web.config files. You can also store local information and settings in virtual directories by creating additional local web. you can share information and settings between Web pages by storing Web application settings in a central location called the web.Configuring an Application by Using Web.config file.config file to share information and settings between Web pages.

2008 12:42 AM Instructor Notes (PPT Text) Emphasize that each level of configuration file overrides the previous level.Configuration Inheritance Saturday. see Module 16. "Securing a Microsoft ASP. and Deploying a Microsoft ASP. Student Book Content Note: For more information about security in the web. September 06. Optimizing.config file.NET Web Application página 312 .NET Web Application."• Module 15-Configuring.

aspx page in the browser.Configuration Inheritance Saturday. 2. and then highlight the value that was retrieved from the web.config file.config file in the child directory. 6.aspx page in the browser. Point out the value that is stored in the Web. 8.config configuration files.aspx page in the SubFolder folder. 2008 12:42 AM Instructor Notes (PPT Text) Use this demonstration to illustrate the previous topic as you discuss it. show the code for the web.config file and Default. September 06.NET Web Application página 313 . CD Content Module 15-Configuring. In the SubFolder folder. Point out that the value that is stored in the web.aspx. Child directories inherit the settings of the parent directories unless the settings are overridden by a web. To run the demonstration 1. Optimizing. In the browser. Student Book Content Configuration Inheritance Key Points The settings in the Machine.config file and GetConfigSubFolder. click Next to open the GetConfigSubFolder.aspx. 11. 5. and Deploying a Microsoft ASP. and then highlight the value that was retrieved from the web. and then point out that the value is the same as the value in the web.In the browser.config. 3. show the code for the web. click Next to open the GetConfigSubFolder. 4. In Microsoft® Visual Studio® 2008.config file. View the Default. in the main folder. In the SubFolder folder. and then emphasize that the value is different here.View the Default. Additional configuration information is contained in the web. which are located in the same directories as the application files.config file in the main directory. rename the web.config file.NET directories and subdirectories.aspx page in the SubFolder folder. Close the browser window 9.Demonstration . Open the ConfigInheritance Web site from the E:\Democode\CS or E:\Democode\VB folder.config file is different.config file apply to all ASP.config file to oldweb. 7. 10.

and Deploying a Microsoft ASP. The Tool contains three sections as follows: The Security tab enables you to manage security settings. September 06. 2008 12:42 AM Instructor Notes (PPT Text) Emphasize that the Web Site Administration Tool provides an easy way to edit configuration files. The Application tab enables you to manage several application-wide settings. Optimizing.Web Site Administration Tool Saturday. The Provider tab enables you to specify where and how to store administration data used by your Web site such as membership data. Student Book Content Web Site Administration Tool Key Points The Web Site Administration Tool enables you to configure your ASP.NET Web Application página 314 . Question: In what situations may you have to take a Web application offline? Module 15-Configuring.NET Web site by using a Web page.

which you use to access the key-value pairs in the <appSettings> and <connectionStrings> sections of the web.config Key Points The WebConfigurationManager class provides the AppSettings and ConnectionStrings properties.Retrieving Data from Web. the WebConfigurationManager class provides the GetSection method.config Saturday.config file. Student Book Content Retrieving Data from Web. Question: In which situations may you want to access the configuration settings of your Web application programmatically? CD Content Module 15-Configuring.NET Web Application página 315 . and Deploying a Microsoft ASP. Optimizing. For other sections in the configuration file. 2008 12:42 AM Instructor Notes (PPT Text) Step through the example code provided to illustrate how to retrieve settings from the Web. September 06.config file.

September 06.config files. Module 15-Configuring. Optimizing.config and web.NET Web Application página 316 .Deploying an ASP. and Deploying a Microsoft ASP. you are ready to deploy your ASP.NET Web Application Saturday. This lesson describes how to select the files that are necessary to run the Web application and then use XCOPY or file transfer protocol (FTP) to copy these files to the production directory.NET Web Application After you set up caching and organize the Web application settings between the Machine. 2008 12:42 AM Instructor Notes (PPT Text) Student Book Content Lesson 4 Deploying an ASP.NET Web application.

The files that are required on the production server include: The bin folder and the DLL files that are in it. and XML Web service files (. Module 15-Configuring. Student Book Content Web Application Deployment Key Points You can choose from several deployment options for your Web application. 2008 12:42 AM Instructor Notes (PPT Text) Mention to the students that they can use a Web Setup project to handle any issues with registration and configuration automatically.aspx. September 06. including web.NET Web Application página 317 .ascx. the folder to which you will deploy your Web application must be configured as an application in Internet Information Services (IIS). and Deploying a Microsoft ASP. Files. .Web Application Deployment Saturday. Before you can deploy a Web application to a production directory. .config configuration files and global. Any additional support files that are in the directory (such as XML files).asax. All Web Form. user control.asmx). Optimizing.

if you do not select the option Allow this precompiled site to be updatable. Question: How can the Publish Web Site utility be useful to you when you develop your own Web applications? CD Content Module 15-Configuring. and Deploying a Microsoft ASP. Optimizing. demonstrate the steps as you describe them.Deploying a Web Application by Using the Publish Web Site Utility Saturday.NET Web Application página 318 . you must recompile the site if you want to make changes. If you have time. Student Book Content Deploying a Web Application by Using the Publish Web Site Utility Key Points An advantage of the Publish Web Site utility is that the source code is removed from the Web site prior to deployment. 2008 12:42 AM Instructor Notes (PPT Text) Explain the steps required to use the Publish Web Site utility. However. September 06.

2008 12:42 AM Instructor Notes (PPT Text) You can open the global assembly cache (GAC) and show the contents. Optimizing.Sharing Assemblies in the Global Assembly Cache Saturday.NET Web Application página 319 . Student Book Content Module 15-Configuring. and Deploying a Microsoft ASP. Provide a few examples of shared assemblies and explain why they are shared. September 06.

2008 12:43 AM Instructor Notes (PPT Text) Emphasize that students can update an application without the requirement to restart IIS.Updating Your Web Application Saturday. and Deploying a Microsoft ASP. the Web server. or the application.NET Web Application página 320 . Student Book Content Module 15-Configuring. September 06. Optimizing.

If you download the AjaxControlToolkit. Optimizing. You can ignore this warning message or download the version of the AjaxControlToolkit.Configuring. optimize.NET Framework 3. students cache a DataSet by using the Cache object.NET Web application. Exercise 4 In this exercise. Before the students begin the lab. students cache a Web Form and a user control by using page output caching. Remind the students to complete the discussion questions after the last lab exercise. Exercise 3 In this exercise.codeplex. Note: The lab exercise answer keys are provided on the Course Companion CD. click the link located at the bottom of the relevant lab exercise page.dll file that targets the official release of . Optimizing. 2008 12:43 AM Instructor Notes (PPT Text) In this lab. Mention this to the students. Exercise 1 In this exercise.dll file. Student Book Content Module 15-Configuring.dll file is not present in the virtual machine. a warning message appears because the AjaxControlToolkit.com Web site.NET Web Application Saturday. students will configure. and Deploying a Microsoft ASP. To access the answer key. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module.5 and Visual Studio 2008 from the www.NET Web Application página 321 . read the scenario associated with each exercise to the class. September 06. Exercise 2 In this exercise.Lab . and deploy a Microsoft ASP. students deploy the Benefits Web site. and Deploying a Microsoft ASP. copy it to the virtual machine to remove the warning message. students implement partial-page caching. Note: When you run the application.

NET Web Application página 322 . and Deploying a Microsoft ASP. In the labs for this course. September 06. Optimizing. 2008 12:43 AM Instructor Notes (PPT Text) Coho Winery offers several benefits to its employees. In this lab. Student Book Content Module 15-Configuring.Exercise 1 . you will optimize and then deploy the Benefits Web site.Caching a DataSet by Using the Cache Object Saturday. you create a Web site that enables employees to select and set up their chosen benefits.

Why? The page is in cache and does not vary by any parameters passed. September 06. Optimizing. other than Publish Web Site. but the selected doctor's name does not appear next to the Primary Care Physician box.aspx page.Exercise 2 . In Exercise 2. 2. can you use to deploy the Web site? Copy web site or Web Setup project.NET Web Application página 323 .aspx page. Task 2. the page is retrieved from cache and will not display a doctor's name. When the page is first loaded into the cache. 1.Reducing Response Times by Using the Page Output Cache Saturday. you are returned to the medical.aspx page? pcp 4. 3. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. Which methods. regardless of what information is returned to the medical. Therefore. In exercise 1. 2008 12:43 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. Student Book Content Module 15-Configuring. it does not display a doctor's name. In Exercise 2. at the end of Task 1. what is the name of the parameter that is passed from the doctors.aspx page to the medical. why do you implement caching in both the Page_Load event procedure and in the list's SelectedIndexChanged event procedure on the doctors Web page? Because the GridView uses DataViews that are based on the city name selected from the list. and Deploying a Microsoft ASP.

Partial-Page Caching Saturday. September 06. Common Issues and Troubleshooting Tips Point the students to possible troubleshooting tips for the issues presented in this section. 2008 12:43 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section. Tools Point out the location from which each key tool can be installed. and Deploying a Microsoft ASP.Exercise 3 . Student Book Content Module 15-Configuring. Optimizing. Let students review the function and usage of each tool on their own. Remind students that they can use this as a master list to help them gather all the tools required to facilitate their application support work.NET Web Application página 324 .

Optimizing. 2008 12:43 AM Student Book Content Module 15-Configuring. September 06.Exercise 4 .NET Web Application página 325 . and Deploying a Microsoft ASP.Deploying Your Site Saturday.

NET Web Application página 326 . September 06. It also explains Secure Sockets Layer (SSL). and IIS authentication mechanisms. 2008 12:44 AM Instructor Notes (PPT Text) Student Book Content Lesson 1 Web Application Security Overview By definition. you can also provide a secure environment that is easy for your users to work in. If you understand and implement suitable security measures for your Web application. you can protect your own resources. Module 16-Securing a Microsoft ASP. This lesson provides an overview of different security concepts: authentication.Web Application Security Overview Saturday. authorization. Web applications provide user access to a central Web server and other database servers.

Question: Does authentication occur before or after authorization or do they both occur at the same time? Module 16-Securing a Microsoft ASP. Determines if the authenticated user has access to a specified resource. Point out that authentication relates to the logon process and authorization relates to permissions.NET Web Application página 327 .Authentication vs. Student Book Content Authentication vs. Authorization Key Points The two fundamental security concepts are as follows: Authentication. 2008 12:44 AM Instructor Notes (PPT Text) Check that the students can confidently provide a definition of authentication and authorization. You can limit access rights by granting or denying specific permissions to an authenticated identity. Authorization. September 06. Authorization Saturday. Obtains user credentials and validates those credentials against some authority such as a database.

The ASP.NET Web Application página 328 . Student Book Content What Are the ASP.NET Authentication Methods? Key Points ASP.NET Web application relies on the Windows operating system to authenticate the user. Non-authenticated requests are redirected to an authentication form by using clientside redirection. Microsoft Passport authentication.NET Authentication Methods Saturday. Forms-based authentication. 2008 12:44 AM Instructor Notes (PPT Text) Distinguish between the two methods of authentication and explain the key features of each. Users are authenticated to access Web sites by using a single Passport account.What Are the ASP. Question: Which authentication method(s) also use IIS authentication? Module 16-Securing a Microsoft ASP. September 06.NET implements authentication by using three types of authentication method: Microsoft Windows ®-based authentication.

however. it is not suitable for most Internet applications.NET Authentication Methods Saturday. Microsoft Passport authentication enables a user to sign in to multiple Webs sites by using a single set of credentials.NET Authentication Methods Key Points Windows-based authentication is appropriate when you have a fixed number of users with existing Windows user accounts. however. however. there is a subscription fee and it is based on cookies. Forms-based authentication is appropriate when you want to set up a custom user registration system. it utilizes cookies to determine the identity of the user. Question: Why is Windows-based authentication not suitable for most Internet applications? Module 16-Securing a Microsoft ASP. September 06. Student Book Content Comparing the ASP. 2008 12:44 AM Instructor Notes (PPT Text) Explain to the students when they can use each authentication method in a Web application.Comparing the ASP.NET Web Application página 329 .

What Are the IIS Authentication Mechanisms Saturday. Briefly explain each IIS authentication mechanism. Similar to Basic authentication. Digest authentication. but it uses an encoded hash to send user information to the server. However. you must first configure the authentication mechanisms in IIS: Anonymous access.NET Web Application página 330 . IIS in turn makes the request to Windows by using the default IUSR_machinename account. 2008 12:44 AM Instructor Notes (PPT Text) Explain to the students that they must configure IIS before they can use Microsoft® Windows® authentication. September 06. it works only with Active Directory ® directory service domain accounts. When IIS receives a request from an anonymous user. Basic authentication. Student Book Content What Are the IIS Authentication Mechanisms? Key Points When you use Windows-based authentication. users without credentials are prompted to supply a user name and password. Mention that NTLM represents 'NT LAN Manager'. Supported by most browsers. Module 16-Securing a Microsoft ASP.

and then click Manage. point out the IIS authentication mechanisms. In this demonstration. In the Connections pane. click Continue. Student Book Content Demonstration: IIS Authentication Mechanisms Question: How can you enable and disable the authentication mechanisms in IIS? CD Content In this demonstration. Mention that IIS is slightly different for each version of Windows. right-click Computer. 6. Enable and disable an authentication mechanism. 8. expand LONDON (LONDON\Stude nt). In the User Account Control dialog box. In the Authentication pane. Display the authentication methods for the deployed Web site In the Computer Management console. and then click Internet Information Services (IIS) Manager. September 06. double-click Authentication. expand Services and Applications. 4. in the left pane. In the Default Web Site Home pane.Demonstration .IIS Authentication Mechanisms Saturday. Module 16-Securing a Microsoft ASP. students will see the IIS authentication mechanisms. expand Web Sites. • 3. Open the Computer Management console Click Start. and then click Default Web Site. 7. 2008 12:44 AM Instructor Notes (PPT Text) • 1. the instructor will show you the authentication mechanisms in IIS. 2. 5. Close the Computer Management console.NET Web Application página 331 .

September 06. server authentication. SSL secures data communication by using data encryption. Explain the term phishing: a type of e-mail scam that steals your identity.NET Web Application página 332 .What Is Secure Sockets Layer Saturday. Module 16-Securing a Microsoft ASP. 2008 12:44 AM Instructor Notes (PPT Text) Do not spend too much time on this topic. The CD content for this slide provide a good overview of Secure Sockets Layer (SSL). and data integrity. Question: How can you prevent one Web site from impersonating another? CD Content IIS provides users with a secure communication channel by supporting the SSL protocol and RSA Data Security encryption on both the server and client. and the students can read these notes at their own pace. Student Book Content What Is Secure Sockets Layer? Key Points SSL is a protocol that you can use to transmit data securely across a network.

NET Web Application página 333 . This lesson explains how to use Windows-based authentication to secure your Web applications.Windows-Based Authentication Saturday. 2008 12:44 AM Instructor Notes (PPT Text) Student Book Content Lesson 2 Windows-Based Authentication You can use Windows-based authentication to secure Web applications when you know which users access your Web site. Module 16-Securing a Microsoft ASP. September 06.

NET Web Application página 334 . Set up authorization in the web. To enable impersonation.NET and is disabled by default. Set up authorization for each secure page in the <location> sections of the web. Student Book Content Enabling Windows-Based Authentication Key Points Securing Web applications by using Windows-based authentication is a four-step process: 1. Set up authentication in the <authentication>. 2. 4. you must configure the web. IIS requests logon information from the users.Enabling Windows-Based Authentication Saturday.config file.config file. <authorization>.config file. Configure IIS. 3.config file. 2008 12:44 AM Instructor Notes (PPT Text) This topic explains the four-step process that you use to secure Web applications by using Windowsbased authentication: 1. IIS requests logon information from your users and grants access if the credentials are valid. Configure IIS to use one or more of its three authentication mechanisms.config file. and <identity> sections of the web. 2. Emphasize that impersonation is optional in ASP. 3. September 06. Set up authentication in the web. Module 16-Securing a Microsoft ASP. 4.

Reading User Information Saturday. 2008 12:44 AM Instructor Notes (PPT Text) Briefly explain the code required to read user information. the IIS authentication mechanism. Mention that User. Module 16-Securing a Microsoft ASP.Identity is not limited to Windows-based authentication. or if the user is authenticated? CD Content After the process of Windows-based authentication is complete. Question: What properties of the User. You can use the User. Student Book Content Reading User Information Key Points When Windows-based authentication is complete. the IIS authentication mechanism.NET Web Application página 335 . September 06.Identityobject to ascertain the user identity.Identityobject can you use to ascertain the user identity. or if the user is authenticated. the Web server can read the user identity from any Web page of the Web application. the Web server can read the user identity from any Web page of the Web application.

Forms-Based Authentication Saturday.NET Web Application página 336 . This lesson describes Forms-based architecture and explains the steps that you use to enable Forms-based authentication. Module 16-Securing a Microsoft ASP. September 06. 2008 12:44 AM Instructor Notes (PPT Text) Student Book Content Lesson 3 Forms-Based Authentication The most common authentication method to secure ASP.config file and create a logon page.NET Web applications is Forms-based authentication. It also demonstrates how to set up security in the web.

Events of Forms-Based Authentication The following events occur during Forms-based authentication: Module 16-Securing a Microsoft ASP. Student Book Content Overview of Forms-Based Authentication Key Points When a user requests a Web page that is protected by Forms-based authentication. you must set IIS authentication to Anonymous access. 2008 12:44 AM Instructor Notes (PPT Text) Ensure that the students understand the sequence of events for Forms-based authentication. the request must first go through IIS. September 06.NET Web Application página 337 . the request must first go through IIS. Therefore. you must set IIS authentication to Anonymous access. CD Content When a user requests a Web page that is protected by Forms-based authentication.Overview of Forms-Based Authentication Saturday. Therefore.

the request first goes through IIS. Student Book Content Multimedia: Forms-Based Authentication Key Points In this animation. the request goes straight to the ASP. The steps are as follows: 1.Forms-Based Authentication Saturday. 2. CD Content In this animation. 2008 12:44 AM Instructor Notes (PPT Text) Explain that the multimedia shows how Forms-based authentication works with a non-authenticated client and with an authenticated client.Multimedia . Module 16-Securing a Microsoft ASP. Because IIS must be configured as Anonymous to use Forms-based authentication. When a non-authenticated client requests a secure page on the Web server.NET Forms authentication module.NET Web Application página 338 . September 06. you will see the implementation of Forms-based authentication with a non-authenticated client and with an authenticated client. you will see the implementation of Forms-based authentication with a non-authenticated client and with an authenticated client.

Student Book Content Enabling Forms-Based Authentication Key Points To enable Forms-based authentication for your Web application: 1. 4. 3. 2008 12:44 AM Instructor Notes (PPT Text) Explain the steps required to enable Forms-based authentication.config file.Enabling Forms-Based Authentication Saturday. Module 16-Securing a Microsoft ASP. Set up authorization in the <authorization> section of the web.config file. 2.NET Web Application página 339 . Create a logon Web Form. Enable Forms-based authentication by configuring IIS to use Anonymous authentication so that the user is authenticated by ASP. Set up authentication in the <authentication> section of the web.NET and not by IIS. September 06.

Module 16-Securing a Microsoft ASP. Question: What ASP. Student Book Content Creating a Logon Page Key Points You can easily create a logon page by using the Login control. display the login controls in the Toolbox of Microsoft Visual Studio®. September 06.NET Web Application página 340 .NET login controls can you add to a Web Form? CD Content You can easily add logon functionality to your Web application by using the ASP.NET provides other login controls that you can access from the Toolbox in Microsoft Visual Studio ®.aspx Web Form that contains logon controls. Add different login controls to a Web page and emphasize their specific login properties. 2008 12:44 AM Instructor Notes (PPT Text) Explain that a logon page is a standard .NET login controls. ASP.Creating a Logon Page Saturday. If time permits.

You can access this secure page because you are an authenticated user.config file.aspx page because you are not an authenticated user and the SecurePageDemo1.aspx page.aspx page.aspx page in design view to display the CreateUserWizard control. Show that the URL contains the SecurePageDemo1. 5.aspx page. Show that you are automatically redirected to the LoginDemo.Forms-Based Authentication Saturday. 3.aspx and SecurityPageDemo2. and then click Log In. In the browser. In Solution Explorer. 6.config 1. If time permits. the instructor will show you how to set up authentication and authorization in the web. click Continue. In the browser. the instructor will demonstrate how the logon page works and then attempt to access secure and nonsecure pages. Module 16-Securing a Microsoft ASP. • Examine the logon and register pages 5. 4. 4.aspx pages to require authorization. Then. • Run the demonstration 7. Open the LogonDemo. 6. In the browser. and then click View in Browser.NET Web Application página 341 . 8.Demonstration . Examine the element that enables Forms authentication and redirects unauthenticated users to the LoginDemo. click the SecurePageDemo2 link. you can also show the students how to publish this Web site to IIS Student Book Content Demonstration: Forms-Based Authentication Question: How can you configure Forms-based authentication? CD Content In this demonstration. In Visual Studio. 2. double-click the web. Register the user name Bob and the password Pa$$w0rd. students will see how implement Forms-based authentication. You cannot access the secure page because you are not a registered user. open the Web site in the E:\Democode\CS\FormsAuthentication or E:\Democode\CS \FormsAuthentication folder. Enter the user name Bob and the password Pa$$w0rd.aspx. 3. right-click NonSecurePage Demo. In Solution Explorer. and then click Create User. Open the RegisterDemo. click the SecurePageDemo1 link. • Examine authentication and authorization in web. click the link to register a new user.config file. September 06. Examine the elements that set the SecurityPageDemo1. 2008 12:44 AM Instructor Notes (PPT Text) In this demonstration.aspx page is a secure page.aspx page in Design view to display the Logon control. You are redirected the SecurePageDemo1.aspx page. 2. You can access the non-secure page. 7. In the browser. You are redirected to the LogonDemo. Close the browser.

Exercise 2 In this exercise. You will then change the Web site to use Forms-based authentication. In this lab.dll file. you want to allow only registered users to access the Web site. students secure a Microsoft ASP. Mention this to the students.NET Web application by using Windows-based and Forms-based authentication. Note: The lab exercise answer keys are provided on the Course Companion CD.NET Web application by using Microsoft Windowsbased authentication.com Web site.aspx so that they do not have to enter this URL multiple times.NET Web Application página 342 . To access the answer key. a warning message appears because the AjaxControlToolkit. 2008 12:44 AM Instructor Notes (PPT Text) In this lab. read the scenario associated with each exercise to the class.NET Web Application Saturday.codeplex. Exercise 1 In this exercise. you will first secure the site by using Windows-based authentication. Student Book Content Lab: Securing a Microsoft ASP. If you download the AjaxControlToolkit. you will implement the registration page to enable users to register with your Web site. Now that you have implemented all of the benefits.Lab .NET Web Application Exercise 1: Securing Your Web Site by Using Windows-Based Authentication Scenario Coho Winery offers several benefits to its employees.dll file is not present in the virtual machine. September 06.Securing a Microsoft ASP. Finally. Module 16-Securing a Microsoft ASP. This will reinforce the broad issue that the students are troubleshooting and will help to encourage the lab discussion at the end of the module. students will secure a Microsoft ASP. Remind the students to complete the discussion questions after the last lab exercise. copy it to the virtual machine to remove the warning message. Mention that students can set the home page of Internet Explorer to http://localhost/Benefits/de fault. students create logon and registration pages.5 and Visual Studio 2008 from the www. Before the students begin the lab.NET Framework 3.dll file that targets the official release of . click the link located at the bottom of the relevant lab exercise page. students secure a Web application by using Forms-based authentication. Exercise 3 In this exercise. Note: When you run the application. You can ignore this warning message or download the version of the AjaxControlToolkit.

In the Physical path box. Finally. and then click Add Application. right-click Default Web Site. passwords are sent by using clear text. In the Internet Information Services Manager dialog box. to be secure. they will implement the registration page to enable users to register with the Web site. Clear the Allow this precompiled site to be updatable check box and then click OK. Minimize Internet Information Services (IIS) Manager. In Solution Explorer. type E:\Benefits and then click OK. Student Book Content Task 7: Publish the Benefits Web site 1. type Benefits 8. Enable Basic Authentication for the Benefits Web site. In the Publish Web Site dialog box. students will first secure the site by using Windows-based authentication. Security Note: Anonymous access is enabled so that you can have both secure and non-secure pages in the same Web application. In a new browser.Securing Your Web Site by Using Windows-Based Authentication Saturday. They will then change the Web site to use Forms-based authentication.Exercise 1 . In this lab. in the Alias box. 2. click Publish Web Site. Task 8: Configure IIS authentication 1. Basic authentication has been enabled without the use of Secure Sockets Layer (SSL). browse to http://localhost/Benefits/default. 6. 2. type E:\Benefits 4. In the Add Application dialog box. On the Build menu. Module 16-Securing a Microsoft ASP. in the Target location box. therefore. September 06. Restore the Internet Information Services Manager dialog box. they want to allow only registered users to access the Web site. 7. In Internet Information Services (IIS) Manager: Verify that Anonymous Authentication is enabled and Windows Authentication is disabled for the Benefits Web site. In a real-world scenario.NET Web Application página 343 . 5. you must obtain a server certificate and implement SSL when you use Basic authentication.aspx. Task 9: Test Windows-based authentication for two pages 2. 2008 12:44 AM Instructor Notes (PPT Text) Now that the students have implemented all of the benefits. For this exercise. 3. click the Benefits Web site.

aspx Web Form to enter the credentials. September 06.Exercise 2 . Configure Forms-based authentication in the web.config file to use Forms-based authentication by denying non-authenticated users access to any page of the Benefits project folder.config file? In the web. set .Securing Your Web Site by Using Forms-Based Authentication Saturday. 2. 2. How can you enable users to sign out of a Web site? You can add a LoginStatus control to a Web site to enable users to sign out.aspx if the user is not authenticated. 3. locate the <authentication> section. Finally.ASPXAUTH and redirect the user to a page named login. Open the web.config file. Configure IIS to use only Anonymous authentication.aspx page and validate user credentials for users of your Web site. 2. Switch to Internet Information Services (IIS) Manager. Task 1: Configure IIS to use only Anonymous authentication 1. 2008 12:44 AM Instructor Notes (PPT Text) Lab Review Questions Use the questions on the slide to guide the debriefing after students have completed the lab exercises. In the web. 4.config file. Module 16-Securing a Microsoft ASP. 4. Switch to Visual Studio 2008. Close the Computer Management console. 3. Test Forms-based authentication. you will create the login. You will then use Forms-based authentication to manage access to secure pages in the Benefits Web site.config file. and then modify it to use Forms-based authentication.config file. 5. you will reconfigure IIS to use Anonymous authentication only. 3. In Internet Information Services (IIS) Manager for the Benefits Web site: Verify that Anonymous Authentication is enabled. How can you configure Forms-based authentication in the web. 3.config file 1. You will configure the web. How can you build a logon form for a Web site? You can use a Login control to create a logon form. you can add elements so that specified pages require authentication. 1. Point the students to the appropriate section in the lab if they are not able to answer the questions presented in this section. Disable Basic Authentication.config file. 2. How can you enable users to register with a Web site? You can add a CreateUserWizard control to a register Web page to enable users to register with a Web site. Add a login. How can you deny access to anonymous users for certain Web pages? In the web. The main tasks for this exercise are as follows: 1. You must create a cookie named . Task 2: Configure Forms-based authentication in the web.NET Web Application página 344 . Student Book Content Exercise 2: Securing Your Web Site by Using Forms-Based Authentication Scenario In this exercise.

NET Web Application página 345 .Module 16-Securing a Microsoft ASP.

3. 2.config file. Test authorized access to the register.aspx file from the E:\Labfiles\Starter\CS\ or E:\Labfiles\Starter\VB\ folder to the Web site. Build the Web site and publish it to E:\Benefits. 2008 12:44 AM Instructor Notes (PPT Text) Review Questions Point the students to the appropriate section in the course so that they are able to answer the questions presented in this section.aspx page to enable users to register with your Web site. You call the SetAuthCookie method because you want to redirect users to the Default.Registering New Users Saturday. write code to authenticate users. Consider why you call the SetAuthCookie method here and not RedirectFromLoginPage.aspx Web Form. September 06.aspx Web Form is called from a link in the login. 5. In the benefitsCreateUserWizard_CreatedUser event handler. Create a CreatedUser event handler for the benefitsCreateUserWizard control.aspx Web Form to register new users. Module 16-Securing a Microsoft ASP. Configure the security for the register. The main tasks for this exercise are as follows: 1. Best Practices Help the students understand the best practices presented in this section.NET Web Application página 346 . Student Book Content Exercise 3: Registering New Users Scenario In this exercise. Usually. create a temporary (non-persistent) authentication cookie by using the UserName property of the control.aspx Web Form to register new users 1. Add a CreateUserWizard control named benefitsCreateUserWizard to the center of the Web Form. the register. 4. Remind students that they can use this as a master list to help them gather all the tools required to facilitate their application support work. which makes no sense. you will add a register.Exercise 3 .aspx page. 4. Tools Point out the location from which each key tool can be installed. 3. Task 2: Attempt to register a new user 1. Attempt to register a new user. Ask students to consider these best practices in the context of their own business situations. Add the register.aspx page. The RedirectFromLoginPage method redirects a newly registered and authenticated user to the login.aspx Web Form. Task 1: Add a register. Let students review the function and usage of each tool on their own. This page contains a title for the Web site. Add a register.aspx page in the web. and then redirect the user to the Default. 2.aspx Web Form.

Sign up to vote on this title
UsefulNot useful