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

Professional Web parts and custom controls with ASP.NET 2.0
PREMIUM
Số trang
482
Kích thước
8.7 MB
Định dạng
PDF
Lượt xem
1162

Professional Web parts and custom controls with ASP.NET 2.0

Nội dung xem thử

Mô tả chi tiết

Professional

Web Parts and Custom Controls

with ASP.NET 2.0

Peter Vogel

01_57860x ffirs.qxd 10/4/05 9:29 PM Page iii

Professional

Web Parts and Custom Controls

with ASP.NET 2.0

01_57860x ffirs.qxd 10/4/05 9:29 PM Page i

01_57860x ffirs.qxd 10/4/05 9:29 PM Page ii

Professional

Web Parts and Custom Controls

with ASP.NET 2.0

Peter Vogel

01_57860x ffirs.qxd 10/4/05 9:29 PM Page iii

Professional Web Parts and Custom Controls

with ASP.NET 2.0

Published by

Wiley Publishing, Inc.

10475 Crosspoint Boulevard

Indianapolis, IN 46256

www.wiley.com

Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN-13: 978-0-7645-7860-1

ISBN-10: 0-7645-7860-X

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

1B/SR/RQ/QV/IN

Library of Congress Cataloging-in-Publication Data

Vogel, Peter, 1953–

Professional Web parts and custom controls with ASP.NET 2.0 / Peter Vogel.

p. cm.

Includes bibliographical references and index.

ISBN-13: 978-0-7645-7860-1 (paper/website : alk. paper)

ISBN-10: 0-7645-7860-X (paper/website : alk. paper)

1. Active server pages. 2. Web sites—Authoring programs. 3. Web site development. 4. Microsoft.net. 5. User interfaces

(Computer systems) 6. Computer software—Development. I. Title.

TK5105.8885.A26V64 2005

005.2 76—dc22

2005021557

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,

electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108

of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization

through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA

01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal

Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or

online at http://www.wiley.com/go/permissions.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESEN￾TATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS

WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF

FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMO￾TIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY

SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN

RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS

REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUB￾LISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGA￾NIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF

FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMA￾TION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER,

READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DIS￾APPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

For general information on our other products and services please contact our Customer Care Department within the

United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade￾marks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries,

and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley

Publishing, Inc., is not associated with any product or vendor mentioned in this book.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in

electronic books.

01_57860x ffirs.qxd 10/4/05 9:29 PM Page iv

About the Author

Peter Vogel (MBA, MCSD) is a principal in PH&V Information Services. PH&V provides consulting ser￾vices in client/server and Web development. Its clients include Volvo, Christie Digital, the Canadian

Imperial Bank of Commerce, the Government of Ontario, and Microsoft. Peter’s white papers appeared

in the Visual Studio .NET and Office 2003 release package. Peter is the editor of the Smart Access news￾letter from Pinnacle Publishing, and wrote The Visual Basic Object and Component Handbook, which has

been called “The definitive guide to ‘thinking with objects.’” Peter was the founding editor of the XML

Developer newsletter. In addition to teaching for Learning Tree International, Peter wrote their ASP.NET

1.1, ASP.NET 2.0, and Technical Writing courses. His articles have appeared in every major magazine

devoted to VB-based development and can be found in the Microsoft Developer Network libraries.

Peter lives in Goderich, Ontario, Canada, and presents at conferences all over the world, frequently as

the keynote speaker.

01_57860x ffirs.qxd 10/4/05 9:29 PM Page v

01_57860x ffirs.qxd 10/4/05 9:29 PM Page vi

Credits

Senior Acquisitions Editor

Jim Minatel

Development Editor

Sara Shlaer

Technical Editors

Derek Comingore

Richard Purchas

Copy Editor

Nancy Rapoport

Editorial Manager

Mary Beth Wakefield

Production Manager

Tim Tate

Vice President and Executive Group Publisher

Richard Swadley

Vice President and Executive Publisher

Joseph B. Wikert

Graphics and Production Specialists

Denny Hager

Joyce Haughey

Barbara Moore

Alicia South

Quality Control Technicians

John Greenough

Leeann Harney

Media Development Specialists

Angela Denny

Kate Jenkins

Steve Kudirka

Kit Malone

Travis Silvers

Media Development Coordinator

Laura Atkinson

Proofreading and Indexing

TECHBOOKS Production Services

01_57860x ffirs.qxd 10/4/05 9:29 PM Page vii

01_57860x ffirs.qxd 10/4/05 9:29 PM Page viii

This book is for my beautiful sons, in order of appearance:

Christopher, Jamie, and Jason.

01_57860x ffirs.qxd 10/4/05 9:29 PM Page ix

01_57860x ffirs.qxd 10/4/05 9:29 PM Page x

Contents

Acknowledgments xix

Introduction xxi

Part I: Introducing Controls 1

Chapter 1: Creating Your Own Controls 3

The Three Kinds of Controls 3

User Controls 4

Custom Controls 5

Web Parts 5

The Benefits of Reusable Controls 6

Beyond Reusability with Web Parts 7

Allowing Customization with Web Parts 7

Implementing Reusability with Controls 9

Controls in Action 10

Exploring the Different Kinds of Controls 13

When to Use a User Control 15

When to Use a Custom Control 15

Web Parts in Action: Customization 16

Providing for Personalization 18

Understanding the Personalization Framework 19

Summary 21

Chapter 2: Creating Customizable Pages 23

The Web Part Framework Controls 24

Creating a Customizable Page 25

Adding Controls to a Zone 27

Wrapping Controls in Web Parts 28

Accessing Controls in a Zone 29

Configuring a Zone 32

Configuring Customization Verbs 32

Configuring the Verb Menu 34

Styling the Zone 34

02_57860x ftoc.qxd 10/4/05 9:30 PM Page xi

xii

Contents

Turning on Customization 36

Customization Tool Controls 39

Editing the Controls with an EditorZone Control 40

Adding New Controls with a CatalogZone Control 44

Configuring the Tool Zones 49

Summary 51

Part II: Creating Controls 53

Chapter 3: Creating Custom Controls 55

Creating a Visual Studio Solution 56

Starting a Custom Control Project 57

Configuring the Solution 57

Staying in Sync 60

Organizing Your Custom Controls 61

An Organization Case Study 62

Extending Existing Controls 66

Creating a Complete Custom Control 68

Adding Constituent Controls 69

Writing HTML 78

Combining Controls and HTML 85

Breaking up the Render Method 87

Supporting AutoPostback 88

Handling Returned Data 92

Controlling Related HTML 96

Design-Time HTML 96

Run-Time HTML 98

Extracting and Controlling WebControl Properties 101

Server-Side Properties 102

Determining the Tag 102

Managing Your Custom Control’s Style 103

Themes and Skins 104

Using Cascading Stylesheet Classes 104

Updating the Style 105

Dealing with Design Mode 113

Managing Code at Design Time 113

Controlling How Visual Studio Handles Your Control 114

Summary 115

02_57860x ftoc.qxd 10/4/05 9:30 PM Page xii

xiii

Contents

Chapter 4: Building User Controls 117

User Controls, WebForms, Custom Controls 117

Starting a User Control 118

Writing Code for Your Control 122

Simulating a Constructor 123

Dynamic Interfaces 124

Using Web Parts 125

Working with a User Control 126

Accessing the Control 129

User Control HTML 130

Summary 130

Chapter 5: Building Web Parts 131

Enabling Personalization for Control Properties 132

Turning on Customization 132

Preserving Customization 133

Sharing Customizations 134

Enabling Customization for Inherited Properties 135

Documenting Properties 135

Creating a Full-Fledged Web Part 136

Checking Personalizable Data 137

Accessing Attributes 137

Adding New Verbs 139

Creating a Verb List 139

Sharing Routines 141

Creating a Verb Routine 142

Configuring the Verb 143

HTML for Web Parts 145

Top Level: The WebPartZone 145

Middle Level: Web Parts 146

Bottom Level: Title Bar 147

Bottom Level 2: Web Part 148

Constituent Control Name and id Attributes 148

Configuring the Web Part 150

Controlling Your Web Part’s User Interface 150

Finding out about Your Web Part 153

Turning off Personalization 154

Providing Help 155

Summary 157

02_57860x ftoc.qxd 10/4/05 9:30 PM Page xiii

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