ASP.NET 2.0 Web Parts in Action ASP.NET 2.0 Web Parts in Action Building Dynamic Web Portals DARREN NEIMKE MANNING Greenwich (74° w. long.) For online information and ordering of this and other Manning books, please go to www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Cherokee Station PO Box 20386 Fax: (609) 877-8256 New York, NY 10021 email: [email protected] ©2007 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Cherokee Station Copyeditor: Sharon Mullins PO Box 20386 Typesetter: Gordan Salinovic New York, NY 10021 Cover designer: Leslie Haimes ISBN 1-932394-77-X Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – VHG – 10 09 08 07 06 To Bill Wilkinson, for teaching me to program brief contents Part 1 Portals and web parts 1 1 Introducing portals and web parts 3 2 Web parts: the building blocks of portals 32 3 Using web part connections 65 4 The Web Part Manager 96 5 Working with zones 127 6 Understanding personalization 158 Part 2 Extending the portal framework 199 7 Creating an enhanced editing experience 201 8 Useful portal customizations 229 9 Portal management 257 10 Into the future 282 appendix Creating the Adventure Works project 310 vii contents foreword xiii preface xiv acknowledgments xv about this book xvi about the title xix about the cover illustration xx Part 1 Portals and web parts 1 1 Introducing portals and web parts 3 1.1 Introduction 3 1.2 What is a portal? 5 Anatomy of a portal 6 ✦ A portal example 8 1.3 Using the ASP.NET 2.0 portal framework 16 Components of the framework 16 1.4 Introducing Adventure Works Cycles database 18 What is the database? 18 ✦ You’re hired! 19 Getting our hands on data 21 1.5 Summary 31 2 Web parts: the building blocks of portals 32 2.1 Introduction 32 2.2 Exploring web parts 33 Discovering the GenericWebPart control 34 2.3 Understanding the WebPart class 38 Using custom controls 38 ✦ Creating web parts with user controls 42 2.4 Understanding web part internals 45 IWebPart 46 ✦ IWebActionable 48 ✦ IWebEditable 52 ix