Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Addison wesley   advanced ASP NET AJAX server controls for  NET framework 3 5 (2008)
PREMIUM
Số trang
645
Kích thước
7.3 MB
Định dạng
PDF
Lượt xem
1250

Addison wesley advanced ASP NET AJAX server controls for NET framework 3 5 (2008)

Nội dung xem thử

Mô tả chi tiết

Praise for Advanced ASP.NET AJAX Server Controls

“If you’re an ASP.NET developer looking for the shortest road to delivering AJAX￾enabled, Web 2.0 applications, Advanced ASP.NET AJAX Server Controls has what

you need. Deliver interactive AJAX functionality that today’s web applications

demand, using tools and methods you already know.”

—Shawn Burke

AJAX Control Toolkit Director, Microsoft

“You know what is frustrating? When I read or hear about a technology, start play￾ing with it, and then dead end because the documentation only covers simple con￾cepts or a reference book just gives you an introduction that is nothing more than

a glorified regurgitation of the documentation. Adam Calderon and Joel Rumerman

take you to the next level as you begin or refine building ASP.NET AJAX Server

Controls. They not only show you how, but dive deep to give you insight and guid￾ance. This book is intended for those who want to go beyond UpdatePanel and

build their own controls. If you are looking for a primer, then look for another book

on the shelf—this is hardcore.”

—Thomas Lewis

Web User Experience Evangelism Manager, Microsoft

“Advanced ASP.NET AJAX Server Controls is the most complete and thorough resource

available for this powerful AJAX framework. The authors have provided tremen￾dous depth into the flexibility and extensibility of the technology for beginning and

advanced developers alike, going far beyond the simple cases covered in other

sources.”

—Jason Schmitt

Vice President of Products, Steelbox Networks

“Kudos to Adam Calderon and Joel Rumerman for tackling the subject of building

AJAX Server Controls. This book is The Red Pill for ASP.NET AJAX Developers (see

the Matrix movie). Custom Controls and components are the .NET Developer’s best

opportunity for code reuse, and this book takes controls building into the AJAX

era.”

—Joe Stagner

Senior Program Manager, Developer Tools & Platforms, Microsoft

This page intentionally left blank

Advanced ASP.NET AJAX

Server Controls

Microsoft .NET Development Series

John Montgomery, Series Advisor

Don Box, Series Advisor

Brad Abrams, Series Advisor

The award-winning Microsoft .NET Development Series was established in 2002 to provide professional

developers with the most comprehensive and practical coverage of the latest .NET technologies. It is

supported and developed by the leaders and experts of Microsoft development technologies, including

Microsoft architects, MVPs, and leading industry luminaries. Books in this series provide a core resource of

information and understanding every developer needs to write effective applications.

Titles in the Series

Brad Abrams, .NET Framework Standard Library

Annotated Reference Volume 1: Base Class Library and

Extended Numerics Library, 978-0-321-15489-7

Brad Abrams and Tamara Abrams, .NET Framework

Standard Library Annotated Reference, Volume 2:

Networking Library, Reflection Library, and XML Library,

978-0-321-19445-9

Chris Anderson, Essential Windows Presentation Foundation

(WPF), 978-0-321-37447-9

Keith Ballinger, .NET Web Services: Architecture and

Implementation, 978-0-321-11359-7

Bob Beauchemin and Dan Sullivan, A Developer’s Guide to

SQL Server 2005, 978-0-321-38218-4

Don Box with Chris Sells, Essential .NET, Volume 1:

The Common Language Runtime, 978-0-201-73411-9

Keith Brown, The .NET Developer’s Guide to Windows

Security, 978-0-321-22835-2

Eric Carter and Eric Lippert, Visual Studio Tools for Office:

Using C# with Excel, Word, Outlook, and InfoPath,

978-0-321-33488-6

Eric Carter and Eric Lippert, Visual Studio Tools for

Office: Using Visual Basic 2005 with Excel, Word, Outlook,

and InfoPath, 978-0-321-41175-4

Mahesh Chand, Graphics Programming with GDI+,

978-0-321-16077-5

Steve Cook, Gareth Jones, Stuart Kent, Alan Cameron

Wills, Domain-Specific Development with Visual Studio

DSL Tools, 978-0-321-39820-8

Krzysztof Cwalina and Brad Abrams, Framework Design

Guidelines: Conventions, Idioms, and Patterns for Reusable

.NET Libraries, 978-0-321-24675-2

Len Fenster, Effective Use of Microsoft Enterprise Library:

Building Blocks for Creating Enterprise Applications and

Services, 978-0-321-33421-3

Sam Guckenheimer and Juan J. Perez, Software

Engineering with Microsoft Visual Studio Team System,

978-0-321-27872-2

Anders Hejlsberg, Scott Wiltamuth, Peter Golde, The C#

Programming Language, Second Edition, 978-0-321-33443-5

Alex Homer and Dave Sussman, ASP.NET 2.0 Illustrated,

978-0-321-41834-0

Joe Kaplan and Ryan Dunn, The .NET Developer’s Guide to

Directory Services Programming, 978-0-321-35017-6

Mark Michaelis, Essential C# 2.0, 978-0-321-15077-6

James S. Miller and Susann Ragsdale,

The Common Language Infrastructure Annotated Standard,

978-0-321-15493-4

Christian Nagel, Enterprise Services with the .NET

Framework: Developing Distributed Business Solutions

with .NET Enterprise Services, 978-0-321-24673-8

Brian Noyes, Data Binding with Windows Forms 2.0:

Programming Smart Client Data Applications with .NET,

978-0-321-26892-1

Brian Noyes, Smart Client Deployment with ClickOnce:

Deploying Windows Forms Applications with ClickOnce,

978-0-321-19769-6

Fritz Onion with Keith Brown, Essential ASP.NET 2.0,

978-0-321-23770-5

Fritz Onion, Essential ASP.NET with Examples in C#,

978-0-201-76040-8

Fritz Onion, Essential ASP.NET with Examples in Visual

Basic .NET, 978-0-201-76039-2

Scott Roberts and Hagen Green, Designing Forms

for Microsoft Office InfoPath and Forms Services 2007,

978-0-321-41059-7

Dr. Neil Roodyn, eXtreme .NET: Introducing eXtreme

Programming Techniques to .NET Developers,

978-0-321-30363-9

Chris Sells and Michael Weinhardt, Windows Forms 2.0

Programming, 978-0-321-26796-2

Dharma Shukla and Bob Schmidt, Essential Windows

Workflow Foundation, 978-0-321-39983-0

Guy Smith-Ferrier, .NET Internationalization:

The Developer’s Guide to Building Global Windows

and Web Applications, 978-0-321-34138-9

Will Stott and James Newkirk, Visual Studio Team

System: Better Software Development for Agile Teams,

978-0-321-41850-0

Paul Vick, The Visual Basic .NET Programming Language,

978-0-321-16951-8

Damien Watkins, Mark Hammond, Brad Abrams,

Programming in the .NET Environment, 978-0-201-77018-6

Shawn Wildermuth, Pragmatic ADO.NET: Data Access

for the Internet World, 978-0-201-74568-9

Paul Yao and David Durant, .NET Compact Framework

Programming with C#, 978-0-321-17403-1

Paul Yao and David Durant, .NET Compact Framework

Programming with Visual Basic .NET, 978-0-321-17404-8

For more information go to www.informit.com/msdotnetseries/

Adam Calderon

Joel Rumerman

Advanced

ASP.NET AJAX

Server Controls

For .NET

Framework 3.5

Upper Saddle River, NJ • Boston • Indianapolis • San Francisco

New York • Toronto • Montreal • London • Munich • Paris

Madrid • Cape Town • Sydney • Tokyo • Singapore • Mexico City

Many of the designations used by manufacturers and

sellers to distinguish their products are claimed as

trademarks. Where those designations appear in this

book, and the publisher was aware of a trademark

claim, the designations have been printed with initial

capital letters or in all capitals.

The .NET logo is either a registered trademark or

trademark of Microsoft Corporation in the United

States and/or other countries and is used under license

from Microsoft.

The authors and publisher have taken care in the

preparation of this book, but make no expressed or

implied warranty of any kind and assume no respon￾sibility for errors or omissions. No liability is assumed

for incidental or consequential damages in connection

with or arising out of the use of the information or pro￾grams contained herein.

The publisher offers excellent discounts on this book

when ordered in quantity for bulk purchases or special

sales, which may include electronic versions and/or

custom covers and content particular to your business,

training goals, marketing focus, and branding inter￾ests. For more information, please contact:

U.S. Corporate and Government Sales

(800) 382-3419

[email protected]

For sales outside the United States please contact:

International Sales

[email protected]

Visit us on the web: www.informit.com/aw

Library of Congress Cataloging-in-Publication Data:

Calderon, Adam, 1964-

Advanced ASP.Net Ajax server controls for .Net 3.5

/ Adam Calderon, Joel Rumerman.

p. cm.

ISBN 0-321-51444-0 (pbk. : alk. paper) 1. Internet

programming. 2. Active server pages. 3. Microsoft

.NET. 4. Ajax (Web site development technology) 5.

Web servers. I. Rumerman, Joel, 1980- II. Title.

QA76.625.C34 2008

006.7’882—dc22

2008013462

Copyright © 2009 Pearson Education, Inc.

All rights reserved. Printed in the United States of

America. This publication is protected by copyright,

and permission must be obtained from the publisher

prior to any prohibited reproduction, storage in a

retrieval system, or transmission in any form or by any

means, electronic, mechanical, photocopying, record￾ing, or likewise. For information regarding permis￾sions, write to:

Pearson Education, Inc.

Rights and Contracts Department

501 Boylston Street, Suite 900

Boston, MA 02116

Fax (617) 671 3447

ISBN-13: 978-0-321-51444-8

ISBN-10: 0-321-51444-0

Text printed in the United States on recycled paper at

RR Donnelly in Crawfordsville, Indiana.

First printing: July 2008

Editor-in-Chief

Karen Gettman

Acquisitions Editor

Joan Murray

Development Editors

Sheri Cain

Chris Zahn

Managing Editor

Kristy Hart

Project Editor

Jovana San Nicolas-Shirley

Copy Editor

Keith Cline

Indexer

WordWise Publishing Services

Proofreader

Geneil Breeze

Publishing Coordinator

Olivia Basegio

Cover Designer

Chuti Prasertsith

Compositor

Bronkella Publishing

To my wife, Gayle, and my son, Derek: You were already accustomed to my

hard work ethic, but I think writing this book took things to the next level.

Your patience and understanding during this long journey provided the

foundation I needed to get through the rough times. I am truly blessed to

have the both of you in my life.

—Adam

To my wife, Stacey: You make even the hard days easy. And to my parents: I

truly am 50 percent of each of you.

—Joel

Contents

Foreword xxv

Preface xxvii

Acknowledgments xxxv

About the Authors xxxix

I Client Code

1 Programming with JavaScript 3

Generally JavaScript 4

JavaScript Introduction 4

Language Attributes 4

Primitive Data Types 6

Strings 8

Objects 9

Variables and Function Arguments 16

Error Handling 25

Delayed Code Execution Using Timeouts and Intervals 30

Object-Oriented JavaScript Programming 39

Abstract Data Types 40

Inheritance 46

2 Microsoft AJAX Library Programming 51

Extending the Built-In JavaScript Types 52

Booleans 52

Dates and Numbers 53

viii Contents

Strings 54

Arrays 55

Extending the Microsoft AJAX Library 60

Classes 60

Interfaces 67

Enumerations 72

Inheritance and Interface Implementation 78

Important New Types 88

Sys.EventHandlerList 88

Sys.StringBuilder 94

Sys.Debug 96

Sys.UI.DomElement 101

Sys.UI.DomEvent 107

Maintaining Scope 112

Delegates 113

Callbacks 115

II Controls

3 Components 121

Components Defined 121

Components, Controls, and Behaviors 122

Sys.Component 125

Defining New Components 129

Creating Components 134

Wrapping Up Components 151

Controls 151

New Concepts 153

Defining a New Control 155

Creating a Control 157

Wrapping Up Controls 159

Behaviors 159

Defining a Behavior 161

Creating a Behavior 162

Wrapping Up Behaviors 167

Contents ix

4 Sys.Application 169

Background Information 169

Creating Sys.Application 170

Type Information 172

Method Information 172

Component Manager 176

Adding a Component 177

Finding a Component 179

Removing a Component 183

Getting Components 184

Initialization Routine 185

Component Creation Process 189

Load Event 198

The Unload Routine 203

Sys.Application.dispose 203

5 Adding Client Capabilities to Server Controls 207

Script-Generation Architecture 208

Behavior and Control Script Generation 208

Script Resources 214

ScriptManager 218

Adding Client-Side Behavior Using the ExtenderControl 220

ExtenderControl Overview 221

Creating an Extender Control 221

Adding Client-Side Functionality Using the ScriptControl 233

ScriptControl Overview 234

Creating a Script Control 237

Adding Client-Side Functionality to Composite Controls Using

the IScriptControl Interface 247

Composite Control Overview 247

IScriptControl Interface 249

Creating the Composite Control 249

x Contents

6 ASP.NET AJAX Localization 255

Localization in ASP.NET 255

Determining What Needs to Be Localized 257

Running under a Particular Culture 261

Localizing Displayed Values 267

Localization in ASP.NET AJAX 277

JavaScript Localization Capabilities 277

ASP.NET AJAX Localization Capabilities 280

7 Control Development in a Partial Postback Environment 317

UpdatePanel Behavior 318

The Effects of a Partial Postback on Client Components 324

Automatic Disposal of Behaviors and Controls 329

Automatic Disposal of Components 337

Manual Disposal of a Component, Control, or Behavior 340

Loading of JavaScript Statements and Files 355

ScriptManager Registration Methods 355

Sys.Application.notifyScriptLoaded() 362

Sys.Application Events 364

The init Event 364

The load Event 365

III Communication

8 ASP.NET AJAX Communication Architecture 371

New Communication Paradigm 372

ASP.NET AJAX 2.0 Extensions Communication Architecture 374

Web Services 375

Page Methods 386

Serialization 388

Server Framework Components 394

Microsoft AJAX Library Communication Architecture 401

Service Proxies 401

Serialization 415

Contents xi

WebRequest 417

Web Request Core 421

9 Application Services 425

ASP.NET 2.0 Membership, Role, and User Profile Services 425

Forms Authentication 426

ASP.NET 2.0 Provider Model 429

Web Site Administration Tool 431

Membership 433

Roles 439

Profiles 444

ASP.NET AJAX Application Services 448

Authentication Service 448

Role Service 453

Profile Service 456

Custom Application Services 460

HTTP Handler Factory and Supporting Classes 462

Service Proxy 473

Configuration 477

IV AJAX Control Toolkit

10 ASP.NET AJAX Control Toolkit Architecture 481

Overview of the Toolkit 482

Reliance on Attributes to Simplify Development 482

Rich Set of .NET Classes 482

Rich Set of JavaScript Classes 483

Support for Animations 483

Composition of the Toolkit 483

Installation 484

Layout of the Solution 484

Server-Based Architecture 486

Attributes 486

Base Classes for Extenders and ScriptControls 491

Designer Classes 495

xii Contents

Client-Based Architecture 499

BehaviorBase Class 500

ControlBase Class 501

Animations 501

Animation Structure and Types 502

Client Architecture 503

Server Architecture 509

11 Adding Client Capabilities to Server Controls Using the

ASP.NET AJAX Control Toolkit 513

Adding Client-Side Behavior Using the ExtenderControlBase 513

Visual Studio 2008 Extender Control Library Template 514

Inheriting from the ExtenderControlBase Class 518

Creating the AjaxControlToolkit.BehaviorBase Class 521

Attaching the Extender to a Control 523

Final Thoughts 523

Adding Design-Time Support to Your Extender Control 524

Default Design-Time Experience 525

Adding Designers and Editors to Properties 526

Adding Animations to Your Extender Control 532

Animations Using the JavaScript API 533

Animations Using the Declarative Method 537

V Appendixes

A JavaScript in Visual Studio 2008 547

IntelliSense 547

Referencing Libraries and Web Services 548

XML Comments 551

B Validating Method Parameters 555

Contents xiii

C ASP.NET Handlers and Modules 559

ASP.NET Application Lifecycle 559

HTTP Handlers 560

Overview of HTTP Handlers 561

Overview of HTTP Handler Factory 562

HTTP Modules 565

Overview of HTTP Modules 565

D Client Error Handling Code 569

ErrorHandler Client Class 569

ErrorEventArgs Client Class 571

ErrorHandler Server Control 571

StackTrace Client Class 572

ErrorDataService Web Service 574

Test Error Page 574

Index 577

xiv Contents

Tải ngay đi em, còn do dự, trời tối mất!