Module 1: Working with ASP.NET

44 455 0
Tài liệu đã được kiểm tra trùng lặp
Module 1: Working with ASP.NET

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Module 1: Working with ASP.NET Contents Overview Introducing ASP.NET Server Controls 13 Adding ASP.NET Code to a Page 23 Handling Page Events 30 Lab 1: Using ASP.NET to Output Text 35 Review 36 Information in this document is subject to change without notice The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property  2000 Microsoft Corporation All rights reserved Microsoft, BackOffice, MS-DOS, Windows, Windows NT, are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries Other product and company names mentioned herein may be the trademarks of their respective owners BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET iii Instructor Notes Presentation: 120 Minutes Lab: 30 Minutes This module provides students with an overview of ASP.NET Students will learn about the main features of ASP.NET and discover the differences between ASP and ASP.NET They will also learn about server controls and see how to add server-side script to an ASP.NET page In the lab, students will add HTML server controls to an ASP.NET page, and then add event procedures for the HTML server controls Students will also add event procedures to the page After completing this module, students will be able to: ! Identify the main features of ASP.NET ! Identify the differences between ASP and ASP.NET ! Describe the working model of ASP.NET ! Describe the architecture of server controls ! Add an HTML server control to a page ! Access the properties and methods of server controls in code ! Add event handlers for page events ! Use the IsPostback property to handle postback forms Materials and Preparation This section provides the materials and preparation tasks that you need to teach this module Required Materials To teach this module, you need the following materials: ! Microsoft® PowerPoint® file 2063A_01.ppt ! Module 1, “ Working with ASP.NET” (2063A_01.doc) ! Lab, “Using ASP.NET to Output Text” (2063A_L01.doc) ! Animation: ASP.NET Execution Model (2063A_01A001.swf) BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY iv Module 1: Working with ASP.NET Preparation Tasks To prepare for this module, you should: ! Read all of the materials for this module ! Complete all the demonstrations ! Complete the lab ! Go through the animation ! Read up material about the NET framework ! Read up material on the various differences between ASP and ASP.NET Demonstration This section provides demonstration procedures that will not fit in the margin notes or are not appropriate for the student notes Adding Server Controls to an ASP.NET Page ! To run this demonstration View the file //localhost/2063/democode/Mod01/server_controls.aspx in Internet Explorer This file has a form with an input box, a list box, and a Submit button When you fill information in the controls and click Submit, the information is lost Edit the page Add a runat="server" attribute to the controls on the page View the page in the browser again View the source of the page to show the changes that were made The controls still lose their values Edi the page and add a runat="server" attribute to the form View the page in the browser again View the source of the page to show the changes that were made The controls now save their values Edit the page and change the controls to intrinsic web controls: asp:textbox, asp:listbox, asp:button View the page in the browser and show the source of the page Adding Code to Controls ! To run this demonstration The file 2063\DemoCode\Mod01\eventproc.aspx has the completed code for this demonstration Open the file //2063/democode/mod01/server_controls.aspx Change the controls back to HTML server controls and add ID attributes to the text box and the listbox: txtName and lstTitle Add a span tag to the bottom of the page: Add an onServerClick attribute to the button that will call the GreetMe procedure BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET v Create a SCRIPT section for server-side code Create the GreetMe sub procedure Sub GreetMe(s As Object, e As EventArgs) spnGreeting.InnerHTML = "Hello " & txtName.Value & _ " I see your occupation is " & lstTitle.Value End Sub View the page in Internet Explorer When you click the button the values of the controls are displayed in the span View the source of the page to show that the server-side code is not included in the page Using PostBack Forms ! To run this demonstration The file 2063\DemoCode\Mod01\postback.aspx has the completed code for this demonstration Open the file //2063/democode/mod01/server_controls.aspx Add a Page_Load event procedure that initializes the text box Sub Page_Load(s As Object, e As EventArgs) txtName.Value = "Enter your name" End Sub View the page in Internet Explorer The text box gets loaded with default text each time In the Page_Load event procedure, check for IsPostBack and only initialize the text box the first time the page is loaded If Not Page.IsPostBack Then txtName.Value = "Enter your name" End If View the page again Now the initial text is only used the first time BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY vi Module 1: Working with ASP.NET Multimedia Presentation This section provides multimedia presentation procedures that not fit in the margin notes or are not appropriate for the student notes ASP.NET Execution Model ! To present the animation: Action Say this Click First Request This is what happens when an aspx is requested for the first time The client sends a request for a page to the ASP.NET server (The request is in the HTTP-GET form) In this animation, the client is requesting the Hello.aspx page The server checks to see whether there is an existing output cache for the requested page, or else if the requested page is already compiled If there is no output cache or compiled code, the source code for the page is interpreted by a parser, and a compiler is invoked The compiler loads the page and compiles the code into an intermediate language (IL) The compiled IL code is used for returning the requested page to the client Click Second Request When the client requests for the same page the second time, the server again checks for an existing output cache or the compiled code If the server finds the compiled code, then notice how the compiler step is omitted and the compiled code is straightaway used for returning the request Click Output Cache This is the other case, when the server finds the requested page in the output cache In this case notice how all the other steps are bypassed and the requested page is directly returned from the output cache BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET vii Module Strategy Use the following strategy to present this module: ! Introducing ASP.NET This section provides students an overview of the NET framework and how ASP.NET fits in that architecture The focus of this section is the ASP.NET architecture; therefore, avoid getting into too many details about the NET architecture The section also talks about the main features of ASP.NET Again avoid getting into the details because the following chapters deal with these features in detail After discussing the main features of ASP, ask students to compare it with ASP and come up with a comprehensive list of differences between ASP and ASP.NET ASP ASP.NET asp files aspx files Can only be scripted using VBScript or JScript Language independent Difficult to reuse code Allows separation of code and content Need to write code for everything Provides server controls Does not support Web services Includes Web services This section also includes a demonstration on using VS.NET This demonstration gives them the familiarity with the VS.NET interface ! Server Controls ASP.NET introduces the concept of server controls that encapsulate common tasks and provide a clean programming model This section provides students with an overview of server controls and how to use them in applications This section also discusses Web controls, but not get into the details of Web controls as these are discussed in detail in Module 2, “Using Web Controls” ! Adding ASP.NET Code to a Page ASP.NET introduces a new way of coding that is very similar to coding in event-driven languages In this section, students will learn how to create a basic ASP.NET page In addition, this section also includes a topic on the major differences between Visual Basic 6.0 and Visual Basic.NET Version 7.0 ! Page Event Life Cycle This section provides students with information on the life cycle of an ASP.NET page It talks about the main events that are involved in a page life cycle The section also includes information on the use of IsPostBack property for postback forms In the demonstration, show them what will happen if you not use the IsPostBack property BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET Overview Topic Objective To provide an overview of the module topics and objectives Lead-in In this module, you will learn about the main features of ASP.NET, and learn how to add server-side script to an ASP.NET page ! Introducing ASP.NET ! Server Controls ! Adding ASP.NET Code to a Page ! Handling Page Events Microsoft's Active Server Pages (ASP) technology is widely used to create dynamic Web sites and applications However, ASP has several limitations, such as the need for redundant and long-winded coding to accomplish simple goals To overcome these limitations of ASP, Microsoft has developed a new technology called ASP.NET, which is a part of the NET strategy for Web development ASP.NET is a unified Web development platform that provides the services necessary for developers to build enterprise-class Web applications In this module you will learn about the main features of ASP.NET and discover the differences between ASP and ASP.NET You will also learn about server controls and see how to add server-side script to an ASP.NET page After completing this module, you will be able to: ! Identify the main features of ASP.NET ! Identify the differences between ASP and ASP.NET ! Describe the working model of ASP.NET ! Describe the architecture of server controls ! Add an HTML server control to a page ! Access the properties and methods of server controls in code ! Add event handlers for page events ! Use the IsPostback property to handle postback forms BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET # Introducing ASP.NET Topic Objective To introduce the topics included in the section Lead-in Before you start using ASP.NET, you should have an overview of ASP.NET and its framework ! The NET Framework ! ASP.NET Features ! Animation: The ASP.NET Execution Model ! Demonstration: Using Visual Studio.NET In this section, you will read an overview of the NET Framework and see how ASP.NET fits in Next, you will learn about the various features of ASP.NET and see a working model You will also learn about the main differences between ASP and ASP.NET BETA MATERIALS FOR MICROSOFT CERTIFIED TRAINER PREPARATION PURPOSES ONLY ... PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET ASP.NET Features Topic Objective To describe the main features of ASP.NET Lead-in ASP.NET includes many features that make ASP.NET a preferred... CERTIFIED TRAINER PREPARATION PURPOSES ONLY Module 1: Working with ASP.NET vii Module Strategy Use the following strategy to present this module: ! Introducing ASP.NET This section provides students... ONLY Module 1: Working with ASP.NET Overview Topic Objective To provide an overview of the module topics and objectives Lead-in In this module, you will learn about the main features of ASP.NET,

Ngày đăng: 23/10/2013, 00:15

Tài liệu cùng người dùng

Tài liệu liên quan