1. Trang chủ
  2. » Khoa Học Tự Nhiên

70 305 70 315 developing web applications with visual basic

741 282 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 741
Dung lượng 2,15 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Be able to create Windows applications using Microsoft Visual Studio .NET ineither the Visual Basic .NET or Visual C# .NET programming language.. Chapter and Appendix Overview This self-

Trang 1

Copyright © 2002 by Microsoft Corporation

Trang 3

addresses, logos, people, places, and events depicted herein are fictitious Noassociation with any real company, organization, product, domain name, e-mailaddress, logo, person, place, or event is intended or should be inferred

Trang 4

Welcome to MCAD/MCSD Training Kit—Developing Web Applications with

Microsoft Visual Basic NET and Microsoft Visual C# NET By completing the

lessons and exercises in this book, you will acquire the skills and knowledgenecessary to develop Web-based applications in Microsoft Visual Basic NET orMicrosoft Visual C#

This book is designed for developers interested in developing Web applications

at an intermediate and advanced level It includes developing server-based

applications that use the NET Framework to present HTML content and retrievedata from client browsers running over the Internet

This book also addresses the objectives of the Microsoft Certified ProfessionalExam 70-305 and Exam 70-315

For more information about becoming a Microsoft CertifiedApplication Developer (MCAD) or a Microsoft Certified SolutionDeveloper (MCSD), see the section titled “The Microsoft CertifiedProfessional Program” later in this introduction

The “Getting Started” section of this introduction provides important setup

instructions that describe the hardware and software requirements to completethe exercises in this course It also provides information about the networkingconfiguration necessary to complete some of the hands-on exercises Read

Trang 5

Developing and Implementing Web Applications with Microsoft Visual Basic NET and Microsoft Visual Studio NET (Exam 70-305).

Developing and Implementing Web Applications with Microsoft Visual C# NET and Microsoft Visual Studio NET (Exam 70-315).

Prerequisites

This course requires that students meet the prerequisites that follow

Be able to create Windows applications using Microsoft Visual Studio NET ineither the Visual Basic NET or Visual C# NET programming language

Have a basic understanding of the object-oriented programming conceptsincluding classes, properties, methods, and events

Understand the fundamental elements in the Hypertext Markup Language(HTML) used to author Web content

Understand how Web content is stored and accessed over the Internet Thisincludes being able to explain the roles of Web servers, Internet protocols, andWeb clients (such as browsers)

The Supplemental Course Materials CD-ROM contains a variety of

informational aids that may be used throughout this book:

eBook A complete electronic version (eBook) of this training kit

Lesson samples Most lessons in this training kit include sample Visual Studioprojects that organize the code and Web forms shown in the training kit Some

Trang 6

Completed labs Each chapter in this training kit concludes with a lab

containing a series of exercises that reinforce the skills you learned Completedversions of these applications are included so that you can compare your

results You can also use these completed applications as a reference if you getstuck while completing an exercise

Required files Practice files, such as sample databases, that are required toperform the hands-on procedures You should use these files when indicated inthe exercises

Sample exam questions To practice taking a certification exam, you can usethe sample exam questions provided on the CD-ROM The sample questionshelp you assess your understanding of the materials presented in this book.About the DVD

The DVD contains a 60-day evaluation edition of Microsoft Visual Studio NETProfessional

The 60-day Evaluation Edition provided with this training is not thefull retail product and is provided only for the purposes of trainingand evaluation Microsoft Technical Support does not support thisevaluation edition

For additional support information regarding this book and the CD-ROM andDVD (including answers to commonly asked questions about installation anduse), visit the Microsoft Press Technical Support Web site at

http://www.microsoft.com/mspress/support/ You can also email

tkinput@microsoft.com, or send a letter to Microsoft Press, Attn: Microsoft

Press Technical Support, One Microsoft Way Redmond, WA 98502-6399

Features of This Book

Trang 7

educational value from the chapter

Each chapter opens with a “Before You Begin” section, which prepares you forcompleting the chapter

The chapters are then divided into lessons Each lesson contains the referenceand procedural information used for a specific skill

The “Summary” section identifies the key concepts from the lesson

The “Lab” section provides hands-on exercises that reinforce each of the skillstaught in each of the chapter lessons The exercises give you an opportunity touse the skills being presented or explore the part of the application being

described Wherever possible, the exercises in a lab build on each other tocreate a complete application by the end of that lab

At the end of each chapter is the “Review” section that you can use to test whatyou have learned

The appendix, “Questions and Answers,” contains all of the questions asked ineach chapter review and the corresponding answers

Trang 8

Italic in syntax statements indicates placeholders for variable information Italic is also used for book titles.

Names of files and folders appear in initial capital letters, except when you are

to type them directly Unless otherwise indicated, you can use lowercase letterswhen you type a file name in a dialog box or at a command prompt

Filename extensions, when they appear without a file name, are in lowercaseletters

Acronyms appear in all uppercase letters

Monospace type represents code samples, examples of screen text, or entriesthat you might type at a command prompt or in initialization files

Chapter and Appendix Overview

This self-paced training kit combines notes, hands-on procedures, and reviewquestions to teach you how to create Web applications with Visual Studio NET

It is designed to be completed from beginning to end, but you can choose a

customized track and complete only the sections that interest you (See the nextsection, “Finding the Best Starting Point for You,” for more information.) If youchoose the customized track option, see the “Before You Begin” section in eachchapter Any hands-on procedures that require preliminary work from precedingchapters refer to the appropriate chapters

The book is divided into the following sections and chapters:

The “About This Book” section contains an overview and introduces the

components of this training kit Read this section thoroughly to get the greatesteducational value from this training kit and to plan which lessons you willcomplete

Chapter 1, “Introduction to Web Programming,” introduces you to the conceptsand terms used throughout this book, including how Web applications work,the parts of a Web application, how the NET Framework is organized, andhow to use the Visual Studio programming environment The sections in thischapter are intended to provide a high-level overview of concepts that are

explained in greater detail in subsequent chapters

Chapter 2, “Creating Web Forms Applications,” teaches how to create a Webapplication using Visual Studio NET and ASP.NET You learn how to start anew project, create a basic user interface, write code to respond to events, and

Trang 9

Chapter 3, “Working with Web Objects,” explains creating and organizingobjects in Visual Studio NET, using the objects provided by ASP.NET, andsaving objects and data between requests to Web forms Visual Basic, VisualC#, and ASP.NET are based on a common framework, so the object-orientedprogramming techniques you learn in this chapter apply through all aspects of.NET programming

Chapter 4, “Creating a User Interface,” demonstrates how to use ASP.NETcontrols to create a user interface for a multi-page Web forms application Thischapter teaches you about different styles of Web forms, how to choose

controls based on the tasks you want to perform, how to validate data fields,and how to navigate between the Web forms in your application

Chapter 5, “Storing and Retrieving Data with ADO.NET,” shows how to useADO.NET to access and modify data stored in SQL and OLE databases fromWeb forms You learn about the data tools included with Visual Studio andhow to use them to create connections to, get records from, and perform

commands on databases You will also learn how to display data on a Webform using either data binding or code Finally, you learn how to use

transactions to maintain the integrity of a database

Chapter 6, “Catching and Correcting Errors,” explains how to deal with

problems that may occur in your application due to external circumstances.This chapter helps you identify, anticipate, and handle these types of problemseffectively within your application

Chapter 7, “Advanced Web Forms Programming,” teaches how to performadvanced programming tasks that don' t fit neatly into any other category.Although you can successfully create Web applications without knowing thetopics covered in this chapter, the lessons found here are an important part ofmainstream Web programming and they help complete your skill set

Chapter 8, “Maintaining Security,” covers how to control access to your Webapplication using the three different techniques that ASP.NET provides foridentifying and authorizing users You also learn how to secure data

transmitted across the Internet so that it cannot be read by others

Chapter 9, “Building and Deploying Web Applications,” describes how topublish your completed Web applications on a Web server for general use You

Trang 10

it continues to perform well as the demands of your users change

Chapter 10, “Testing Web Applications,” teaches how to systematically testyour Web application during development You learn how to plan, create, run,and correct problems found by tests

Chapter 11, “Creating Custom Web Controls,” demonstrates how to createyour own, custom user-interface components This chapter explains the

different types of controls you can create, describes the relative advantages ofeach, and shows you how to create each different type of control

Chapter 12, “Working with Multimedia,” shows how to add sound, video, andanimation to Web applications and how to control their display and playback incode

Chapter 13, “Formatting Web Application Output,” teaches you how to formatthe user interface of a Web application using cascading style sheets (CSS) andExtensible Stylesheet Language Transformations (XSLT) This chapter

explains the best uses for each formatting technique and tells you how to

combine the two techniques

Chapter 14, “Providing Help,” discusses the different ways that you can

display user assistance (Help) from within a Web application You learn how touse the HTML Help Workshop to create compiled Help files, and how to

display those files from a Web application interactively

Chapter 15, “Globalizing Web Applications,” explains how to detect a user' sculture and create appropriate responses, ranging from redirecting the user to aseparate, localized Web application, to handing cultural differences within codeand displaying a localized user interface

The appendix, “Questions and Answers,” lists all of the review questions fromthe book, showing the page number for each question and the suggested

Trang 11

about specific topics from the

exam

Use the “Where to Find Specific Skills in ThisBook” section that follows this table

Where to Find Specific Skills in This Book

The following tables provide a list of the skills measured on certification Exam

70-305, Developing and Implementing Web Applications with Microsoft Visual

Basic NET and Microsoft Visual Studio NET, or Exam 70-315, Developing and Implementing Web Applications with Microsoft Visual C# NET and Microsoft Visual Studio NET The table provides the skill, and where in this book you will

find the lesson relating to that skill

Exam skills are subject to change without prior notice and at the solediscretion of Microsoft

controls, user controls, and HTML code to

ASP.NET pages:

Set properties on controlsLoad controls dynamicallyApply templatesSet styles on ASP.NET pages by using

cascading style sheets

Chapter 4, Lessons 1 and 2Chapter 4, Lesson 1Chapter 4, Lesson 1Chapter 4, Lesson 1, andChapter 5, Lesson 2Chapter 13, Lesson 1Chapter 12, Lessons 1 and 2

Trang 12

Implement navigation for the user interface:

Manage the view stateManage data during post-back events

Validate non-Latin user input

Chapter 4, Lesson 2Chapter 15, Lesson 3Implement error handling in the user interface:

Implement online user assistance Chapter 14, Lessons 1, 2, and

3Incorporate existing code into ASP.NET pages Chapter 1, Lesson 2

Display and update data:

Transform and filter dataBind data to the user interface

Use controls to display data

Chapter 4, Lesson 1Chapter 5, Lessons 1 and 2;Chapter 13, Lesson 2Chapter 4, Lesson 1Chapter 4, Lesson 1Instantiate and invoke Web services or

components:

Instantiate and invoke a Web service

Instantiate and invoke a COM or COM+

componentInstantiate and invoke a NET component

Chapter 7, Lesson 4Chapter 7, Lesson 4Chapter 10, Lesson 2Chapter 3, Lesson 1

Implement globalization:

Implement localizability for the user

interfaceConvert existing encodings

Implement right-to-left and left-to-right

mirroringPrepare culture-specific formatting

Chapter 15, Lesson 2Chapter 15, Lesson 3Chapter 15, Lesson 1Chapter 15, Lesson 1

Handle events:

Create event handlersRaise events

Chapter 2, Lesson 2

Trang 13

Implement accessibility features Chapter 13, Lesson 1Use and edit intrinsic objects, including

response, request, session, server, and

application:

Retrieve values from the properties of

intrinsic objectsSet values on the properties of intrinsic

objectsUse intrinsic objects to perform operations

Chapter 9, Lesson 1, and Chapter 11,

Lesson 3Chapter 15, Lesson 2Chapter 15, Lesson 2Consuming and Manipulating Data

relational databases, XML documents, and flat files Methods

include XML technique and ADO.NET

Chapter

5, Lesson1Handle data errors

Chapter

6, Lesson1Testing and Debugging

Lesson 1Implement tracing:

Add trace listeners and trace switches to an application

Display trace output

Chapter 10,Lesson 3Chapter 6,Lesson 3Debug, rework, and resolve defects in code:

Chapter 10,Lesson 3

Trang 14

Create and apply debugging code to components, pages,

and applicationsProvide multicultural test data to components, pages, and

applicationsExecute testsResolve errors and rework code

Chapter 10,Lesson 1Chapter 15,Lesson 2Chapter 10,Lesson 2Chapter 10,Lesson 3Deploying a Web Application

Lesson 2Add assemblies to the global assembly cache Chapter 9,

Lesson 2Maintaining and Supporting a Web Application

Skill Being Measured Location in Book

Configure a Web application:

Modify the Web.config fileModify the Machine.config fileAdd and modify application settings

Chapter 9, Lesson 1Chapter 9, Lesson 1;Chapter 8, Lesson 1;and Chapter 15,Lesson 3Chapter 9, Lesson 1Chapter 9, Lesson 1;Chapter 8, Lesson 1;and Chapter 15,Lesson 3

Trang 15

Use a cache objectUse cache directives

Install and configure server services:

Install and configure a Web server

Install and configure FrontPage Server Extensions

Chapter 2, Lesson 1Chapter 2, Lessons 1and 3; Chapter 6,Lesson 2; Chapter 8,Lessons 1 and 5; andChapter 9, Lesson 2Chapter 2, Lesson 1,and Chapter 9, Lesson

3Getting Started

This self-paced training kit contains hands-on procedures to help you learn aboutdeveloping Web applications

To complete some of these procedures, you must have two networked computers

or be connected to a larger network Both computers must be capable of runningMicrosoft Windows XP Professional Edition or Windows 2000

Trang 16

Hardware Requirements

Each computer must have the following minimum configuration All hardwareshould be on the Microsoft Windows XP or Microsoft Windows 2000 HardwareCompatibility List

Pentium II–class processor, 450 megahertz (MHz)

160 MB physical memory, 256 MB recommended

CD-ROM or DVD drive, 12x or faster recommended

A DVD drive is required to install the Visual Studio NETProfessional Evaluation Edition software

Trang 17

Microsoft Visual Studio NET Professional Edition or Visual Studio NET

Enterprise Developer Professional Edition is recommended, and EnterpriseDeveloper Edition is ideal

If AutoRun is disabled on your machine, refer to the Readme.txtfile on the CD-ROM

2 Click Lesson Files on the user interface menu to start the install program

After you run that installer, you' ll need to run the following scripts to set up thevirtual directories required to run these applications in IIS:

Trang 18

D:\MCSDWebApps

The eBook

The CD-ROM also includes an electronic version of the book that you can viewusing a Hypertext Markup Language (HTML) browser

To use the eBook

1 Insert the Supplemental Course Materials CD-ROM into your CD-ROMdrive

If AutoRun is disabled on your machine, refer to the Readme.txtfile on the CD-ROM

Trang 19

2 Click Training Kit eBook on the user interface menu and follow the

prompts

You must have the Supplemental Course Materials CD-ROMinserted in your CD-ROM drive to run the eBook

Sample Exam Questions

To install the sample exam questions to your hard disk drive

1 Insert the Supplemental Course Materials CD-ROM into your CD-ROMdrive

If AutoRun is disabled on your machine, refer to the Readme.txtfile on the CD-ROM

2 Click Sample Exam Questions on the user interface menu and then selectthe exercise file you want to view

Trang 20

.NET Qualified to develop and maintain department-level applications,

components, Web or desktop clients, or back-end data services

Microsoft Certified Solution Developer (MCSD) Qualified to design anddevelop custom business solutions with Microsoft development tools,

technologies, and platforms and Microsoft Windows architecture

Microsoft Certified Professional (MCP) Demonstrated in-depth knowledge of

at least one Microsoft Windows operating system or architecturally significantplatform An MCP is qualified to implement a Microsoft product or technology

as part of a business solution for an organization

Microsoft Certified Systems Engineer (MCSE) on Windows 2000 Qualified

to effectively analyze the business requirements and design and implement theinfrastructure for business solutions based on the Microsoft Windows 2000platform and Microsoft NET Enterprise Servers

Microsoft Certified Systems Administrator (MCSA) on Microsoft Windows

2000 Individuals who implement, manage, and troubleshoot existing networkand system environments based on the Microsoft Windows 2000 and Windows.NET Server operating systems

Microsoft Certified Database Administrator (MCDBA) on Microsoft SQLServer 2000 Individuals who derive physical database designs, develop

logical data models, create physical databases, create data services by usingTransact-SQL, manage and maintain databases, configure and manage security,monitor and optimize databases, and install and configure Microsoft SQLServer

Microsoft Certified Trainer (MCT) Instructionally and technically qualified todeliver Microsoft Official Curriculum through a Microsoft Certified TechnicalEducation Center (CTEC)

Microsoft Certification Benefits

Microsoft certification, one of the most comprehensive certification programsavailable for assessing and maintaining software-related skills, is a valuablemeasure of an individual' s knowledge and expertise Microsoft certification isawarded to individuals who have successfully demonstrated their ability to

perform specific tasks and implement solutions with Microsoft products Notonly does this provide an objective measure for employers to consider, it also

Trang 21

Access to technical and product information direct from Microsoft through asecured area of the MCP Web site (go to

MCP logo, certificate, transcript, wallet card, and lapel pin to identify you as aMicrosoft Certified Professional (MCP) to colleagues and clients Electronicfiles of logos and transcript may be downloaded from the MCP secured Website (go to http://www.microsoft.com/traincert/mcp/mcpsecure.asp/) uponcertification

Invitations to Microsoft conferences, technical training sessions, and specialevents

Free access to Microsoft Certified Professional Magazine Online, a career andprofessional development magazine Secured content on the Microsoft

Certified Professional Magazine Online Web site includes the current issue(available only to MCPs), additional online-only content and columns, anMCP-only database, and regular chats with Microsoft and other technicalexperts

Trang 22

Association for SQL Server In addition to playing a key role in the only

worldwide, user-run SQL Server user group endorsed by Microsoft, membersenjoy unique access to a world of educational opportunities (go to

http://www.microsoft.com/traincert/mcp/mcpsecure.asp/)

An additional benefit is received by Microsoft Certified System Engineers

(MCSEs):

A 50-percent rebate or discount off the estimated retail price of a one-yearsubscription to TechNet or TechNet Plus during the first year of certification.(Fulfillment details will vary, depending on your location Please see yourWelcome Kit.) In addition, about 95 percent of the CD-ROM content is

available free online at the TechNet Web site

(http://www.microsoft.com/technet/)

A one-year subscription to SQL Server Magazine Written by industry experts,the magazine contains technical and how-to tips and advice—a must for

anyone working with SQL Server

A list of benefits for Microsoft Certified Trainers (MCTs) can be found at

http://www.microsoft.com/traincert/mcp/mct/benefits.asp

Microsoft Certification Benefits for Employers and Organizations

Through certification, computer professionals can maximize the return on

investment in Microsoft technology Research shows that Microsoft certificationprovides organizations with:

Trang 23

standard method of determining training needs and measuring results

Increased customer satisfaction and decreased support costs through improvedservice, increased productivity, and greater technical self-sufficiency

Reliable benchmark for hiring, promoting, and career planning

Recognition and rewards for productive employees by validating their

expertise

Retraining options for existing employees so they can work effectively withnew technologies

Assurance of quality when outsourcing computer services

Requirements for Becoming a Microsoft

Certified Professional

The certification requirements differ for each certification and are specific to theproducts and job functions addressed by the certification

To become a Microsoft Certified Professional, you must pass rigorous

certification exams that provide a valid and reliable measure of technical

proficiency and expertise These exams are designed to test your expertise andability to perform a role or task with a product, and are developed with the input

of professionals in the industry Questions in the exams reflect how Microsoftproducts are used in actual organizations, giving them “real-world” relevance

Microsoft Certified Product candidates are required to pass one operatingsystem exam Candidates may pass additional Microsoft certification exams tofurther qualify their skills with other Microsoft products, development tools, ordesktop applications

Microsoft Certified Systems Engineers are required to pass five core examsand two elective exams

Microsoft Certified Systems Administrators are required to pass three coreexams and one elective exam that provide a valid and reliable measure of

technical proficiency and expertise

Microsoft Certified Database Administrators are required to pass three coreexams and one elective exam that measures technical proficiency and

Trang 24

Microsoft Certified Solution Developers are required to pass three core

Microsoft Windows operating system technology exams and one BackOfficetechnology elective exam

Microsoft Certified Trainers are required to meet instructional and technicalrequirements specific to each Microsoft Official Curriculum course they arecertified to deliver The MCT program requires ongoing training to meet therequirements for the annual renewal of certification For more informationabout becoming a Microsoft Certified Trainer, visit

http://www.microsoft.com/traincert/mcp/mct/ or contact a regional servicecenter near you

Technical Training for Computer

Professionals

Technical training is available in a variety of ways, with instructor-led classes,online instruction, or self-paced training available at thousands of locationsworldwide

Self-Paced Training

For motivated learners who are ready for the challenge, self-paced instruction isthe most flexible, cost-effective way to increase your knowledge and skills

A full-line of self-paced print and computer-based training materials is availabledirect from the source—Microsoft Press Microsoft Official Curriculum

courseware kits from Microsoft Press are designed for advanced computer

system professionals and are available from Microsoft Press and the MicrosoftDeveloper Division Self-paced training kits from Microsoft Press feature print-based instructional materials, along with CD-ROM-based product software,multimedia presentations, lab exercises, and practice files The Mastering Seriesprovides in-depth, interactive training on CD-ROM for experienced developers.They' re both great ways to prepare for Microsoft Certified Professional (MCP)exams

Online Training

Trang 25

an online instructor Without ever leaving your desk, you can gain the expertiseyou need Online instruction covers a variety of Microsoft products and

technologies It includes options ranging from Microsoft Official Curriculum tochoices available nowhere else It' s training on demand, with access to learningresources 24 hours a day Online training is available through Microsoft

Certified Technical Education Centers

Microsoft Certified Technical Education Centers

Microsoft Certified Technical Education Centers (CTECs) are the best source forinstructor-led training that can help you prepare to become a Microsoft CertifiedProfessional The Microsoft CTEC program is a worldwide network of qualifiedtechnical training organizations that provide authorized delivery of MicrosoftOfficial Curriculum courses by Microsoft Certified Trainers to computer

professionals

For a listing of CTEC locations in the United States and Canada, visit the Website at /">http://www.microsoft.com/traincert/ctec/

Technical Support

Every effort has been made to ensure the accuracy of this book and the contents

of the companion disc If you have comments, questions, or ideas regarding thisbook or the companion disc, please send them to Microsoft Press using either ofthe following methods:

Trang 26

For information about ordering the full version of any Microsoft software, pleasecall Microsoft Sales at (800) 426-9400 or visit http://www.microsoft.com

Trang 27

Before You Begin

To complete the lessons in this chapter, you must have

Installed Visual Studio NET on your computer

Internet access through a local area network (LAN), broadband, or modemconnection

Trang 28

Web applications are one of four types of Internet applications that you can

create using Visual Studio NET and Microsoft ASP.NET In this lesson, you willlearn a little about the different types of Internet applications and get an

overview of how a Web application works

After this lesson, you will be able to

Describe four different types of Internet applications and know where to lookfor training on developing each type of application

Explain how a Web application executes over the Internet and how that differsfrom a traditional, static Web site

Understand the role that ASP.NET plays in creating Web applications

List the parts that make up ASP.NET and describe some of its advantages overother Web application technologies, such as the Common Gateway Interface(CGI)

Web services These components provide processing services from a server toother applications over the Internet

Trang 29

System.Web.Services

namespace

MCSD Training Kit: Developing Web Services and Server Components

Internet-enabled

applications

Windows forms,HTML Help,WebBrowser

control, System.Net

namespace

MCSD Training Kit: Developing Windows Applications with the Microsoft NET Framework or Desktop Applications with Microsoft Visual C++ 6.0 MCSD Training

Kit

Peer-to-peer

applications

Accessing theInternet, pluggableprotocols,

System.Net.Sockets

namespace

MCSD Training Kit: Developing Web Services and Server Components

How Web Applications Work

Web applications use a client/server architecture The Web application resides on

Trang 30

Figure 1-1

Web application architecture

On the client side, the Web application is hosted by a browser, such as InternetExplorer or Netscape Navigator The application' s user interface takes the form

of Hypertext Markup Language (HTML) pages that are interpreted and

displayed by the client' s browser

On the server side, the Web application runs under Microsoft Internet

Information Services (IIS) IIS manages the application, passes requests fromclients to the application, and returns the application' s responses to the client.These requests and responses are passed across the Internet using Hypertext

Transport Protocol (HTTP) A protocol is a set of rules that describe how two or

more items communicate over a medium, such as the Internet Figure 1-2 showshow the client and server interact over the Internet

Figure 1-2

Client/server interaction in a Web application

The Web application composes responses to requests from resources found onthe server These resources include the executable code running on the server(what we traditionally think of as the “application” in Microsoft Windows

programming), Web Forms, HTML pages, image files, and other media thatmake up the content of the application

Web applications are much like traditional Web sites, except that the contentpresented to the user is actually composed dynamically by executable, ratherthan being served from a static page stored on the server Figure 1-3 shows how

a Web application composes the HTML returned to a user

Figure1-3

A Web application response from server resources

The executable portion of the Web application enables you to do many things

Trang 31

Collect information from the user and store that information on the server.Perform tasks for the user such as placing an order for a product, performingcomplex calculations, or retrieving information from a database

Identify a specific user and present an interface that is customized for him orher

Present content that is highly volatile, such as inventory, pending order, andshipment information

This is only a partial list Basically, you can do anything with a Web applicationthat you can imagine doing with any client/server application What makes aWeb application special is that the client/server interaction takes place over theInternet

What ASP.NET Provides

ASP.NET is the platform that you use to create Web applications and Web

services that run under IIS ASP.NET is not the only way to create a Web

application Other technologies, notably the CGI, also enable you to create Webapplications What makes ASP.NET special is how tightly it is integrated withthe Microsoft server, programming, data access, and security tools

ASP.NET provides a high level of consistency across Web application

development In a way, it is similar to the level of consistency that MicrosoftOffice brought to desktop applications ASP.NET is part of the NET Frameworkand is made up of several different components

Visual Studio NET Web development tools These include visual tools fordesigning Web pages and application templates, project management, anddeployment tools for Web applications

The System.Web namespaces These are part of the NET Framework, andinclude the programming classes that deal with Web-specific items such asHTTP requests and responses, browsers, and e-mail

Server and HTML controls These are the user-interface components that youuse to gather information from and provide responses to users

Trang 32

Microsoft Internet Information Services (IIS) As mentioned in the previoussection, IIS hosts Web applications on the Windows server

The Microsoft Visual Basic NET, Microsoft Visual C#, and JScript

programming languages These three languages have integrated support inVisual Studio NET for creating Web applications

The NET Framework This is the complete set of Windows programmingclasses; they include the ASP.NET classes as well as classes for other

programming tasks such as file access, data type conversion, array and stringmanipulation, and so on

ADO.NET database classes and tools These components provide access toMicrosoft SQL Server and ODBC databases Data access is often a key

component of Web applications

Microsoft Application Center Test (ACT) This Visual Studio NET

component provides an automated way to stress-test Web applications

ASP.NET is the most complete platform for developing Web applications thatrun under IIS However, it is important to remember that ASP.NET is not

platform-independent Because it is hosted under IIS, ASP.NET must run onWindows servers To create Web applications that run on non-Windows/IISservers, such as Linux/Apache, you must use other tools—generally CGI

Advantages of ASP.NET

ASP.NET has many advantages over other platforms when it comes to creatingWeb applications Probably the most significant advantage is its integration withthe Windows server and programming tools Web applications created withASP.NET are easier to create, debug, and deploy because those tasks can all beperformed within a single development environment—Visual Studio NET

ASP.NET delivers the following other advantages to Web application

developers:

Executable portions of a Web application compiled so they execute more

Trang 33

On-the-fly updates of deployed Web applications without restarting the serverAccess to the NET Framework, which extends the Windows API

Use of the widely known Visual Basic programming language, which has beenenhanced to fully support object-oriented programming

Introduction of the new Visual C# programming language, which provides atype-safe, object-oriented version of the C programming language

Automatic state management for controls on a Web page (called server

controls) so that they behave much more like Windows controls

The ability to create new, customized server controls from existing controlsBuilt-in security through the Windows server or through other

authentication/authorization methods

Integration with Microsoft ADO.NET to provide database access and databasedesign tools from within Visual Studio NET

Full support for Extensible Markup Language (XML), cascading style sheets(CSS), and other new and established Web standards

Built-in features for caching frequently requested Web pages on the server,localizing content for specific languages and cultures, and detecting browsercapabilities

Trang 34

In this lesson, you will learn how ASP.NET organizes a Web application intoparts, and you will learn the roles and names of those parts You will be

introduced to Web Forms, which are the central user-interface element of Webapplications

ASP.NET is part of the larger NET Framework, so this lesson will also discusshow the NET Framework is organized and how NET applications run

differently from the traditional Windows applications you might be used to

Finally, this lesson ends with a discussion of the programming languages youcan use to create Web applications ASP.NET is not bound to any one

programming language, and the end of this lesson lists some of the other

available languages and explains some of the major differences between the twolanguages (Visual Basic NET and Visual C#) featured in this book

After this lesson, you will be able to

List the parts of a Web application and describe how they run on the serverExplain how a Web form differs from and is similar to both an HTML pageand a Windows form

Describe some of the different components you can place on a Web form

time (CLR) executes NET applications

Explain the parts of the NET Framework and how the common language run-Understand how the NET Framework is organized and know where to look forclasses that handle common application programming tasks

Trang 35

database query)

Program

logic

Executablefiles, scripts

The program logic determines how theapplication responds to user actions ASP.NETWeb applications have a dynamic-link library(DLL) file that runs on the server, and they canalso include scripts that run on the client

machine

Configuration

Webconfigurationfile, Stylesheets, IISsettings

The configuration files and settings determinehow the application runs on the server, who hasaccess, how errors are handled, and other details

The Web form is the key element of a Web application A Web form is a crossbetween a regular HTML page and a Windows form: It has the same appearanceand similar behavior to an HTML page, but it also has controls that respond toevents and run code, like a Windows form

Trang 36

1 IIS starts the Web application' s executable if it is not already running.

2 The executable composes a response to the user based on the content of theWeb Forms page that the user requested and any program logic that

provides dynamic content

3 IIS returns the response to the user in the form of HTML

Once the user gets the requested Web form, he or she can enter data, select

options, click buttons, and use any other controls that appear on the page Somecontrols, such as buttons, cause the page to be posted back to the server for eventprocessing and the sequence repeats itself, as shown in Figure 1-5

These controls respond to user events byrunning event procedures on the server.Server controls have built-in features forsaving data that the user enters betweenpage displays You use server controls todefine the user interface of a Web form

HTML

controls

Text area, Table, Image, Submit Button, Reset Button

These represent the standard visualelements provided in HTML HTMLcontrols are useful when the more completefeature set provided by server controls is

not needed

SqlConnection,

Trang 37

controls

SqlCommand, OleDbConnection, OleDbCommand, DataSet

Data controls provide a way to connect to,perform commands on, and retrieve datafrom SQL and OLE databases and XML

data files

System

components

FileSystemWatcher, EventLog, MessageQueue

These components provide access tovarious system-level events that occur on

the server

You use the server and HTML controls to create the user interface on a Webform The data controls and system components appear on the Web form only atdesign time to provide a visual way for you to set their properties and handletheir events At run time, data controls and system components do not have avisual representation Figure 1-6 shows a Web form containing components

Figure 1-6

A Web form with components

Chapter 4, “Creating a User Interface,” provides more detail about using serverand HTML controls on a Web form

The NET Framework

ASP.NET is an important part of the NET Framework, but it is just one part.Understanding what else the NET Framework provides will help you programyour ASP.NET application effectively and avoid writing new code to performtasks that are already implemented within the NET Framework

Trang 38

Microsoft intermediate language (MSIL) and stored in a file called an assembly

At run time, the assembly is compiled to its final state by the CLR While

running, the CLR provides memory management, type-safety checks, and otherrun-time tasks for the application Figure 1-7 shows how this works

Figure 1-7

How a NET application runs

Applications that run under the CLR are called managed code because the CLRtakes care of many of the tasks that would have formerly been handled in theapplication' s executable itself Managed code solves the Windows programmingproblems of component registration and versioning (sometimes called DLL Hell)because the assembly contains all the versioning and type information that theCLR needs to run the application The CLR handles registration dynamically atrun time, rather than statically through the system registry as is done with

applications based on the Common Object Model (COM)

The NET class library provides access to all the features of the CLR The NETclass library is organized into namespaces Each namespace contains a

Trang 39

System.Data, System.Data.Common, System.Data.OleDb, System.Data.SqlClient, System.Data.SqlTypes

These classes includemethods for connecting

to databases, performingcommands, retrievingdata, and modifying

Accessing the filesystem These includemethods for reading andwriting files and gettingpaths and filenames

Network

communication System.Net, System.Net.Sockets

Communicating over theInternet using low-levelprotocols such asTCP/IP These classesare used when creatingpeer-to-peerapplications

Security

System.Security, System.Security.Cryptography, System.Security.Permissions, System.Security.Policy, System.Web.Security

Providing userauthentication, userauthorization, and dataencrypting

Web

applications

System.Web, System.Web.Caching, System.Web.Configuration, System.Web.Hosting, System.Web.Mail, System.Web.SessionState, System.Web.UI, System.Web.UI.Design, System.Web.UI.WebControls, System.Web.UI.HtmlControls

Creating client-serverapplications that runover the Internet Theseare the core classes used

to create ASP.NET Webapplications

Web services

System.Web.Services, System.Web.Services.Configuration, System.Web.Services.Description,

Creating and publishingcomponents that can beused over the Internet.These are the core

Trang 40

System.Web.Services.Discovery, System.Web.Services.Protocols

classes used to createASP.NET Web services

Windows

applications

System.Windows.Forms, System.Windows.Forms.Design

Creating applicationsusing the MicrosoftWindows user interfacecomponents Theseclasses provideWindows forms andcontrols as well as theability to create custom

controls

XML data

System.Xml, System.Xml.Schema, System.Xml.Serialization, System.Xml.Xpath, System.Xml.Xsl

Ngày đăng: 25/03/2019, 17:14

TỪ KHÓA LIÊN QUAN