Praise for SharePoint 2010 Development with Visual Studio 2010 “The fact is, developers are either limited or liberated by the tools they use. This book brings a strong tools focus with Visual Studio 2010, and the authors are the experts when it comes to the tooling enhancements that vastly improve developing with SharePoint 2010. This book is the must-have SharePoint 2010 developer instruction resource for all ranges of experience, novice to expert.” —John R. Durant, Senior Product Manager, Microsoft “I thoroughly enjoyed reading this SharePoint 2010 development book. Every chapter had useful information that was to the point and developer focused—a great addition to any SharePoint developer’s library.” —Greg Galipeau, Director, SharePoint Practice, Optimos Consulting “As a developer, you’re always looking for new opportunities, and SharePoint offers plenty. Visual Studio 2010 adds a great set of tools for working with SharePoint 2010 and Eric Carter, Boris Scholl, and Peter Jausovec do an excel- lent job of explaining how to use them. After reading this book, you’ll know what to do to begin building professional SharePoint solutions.” —Robert Green, Senior Consultant, MCW Technologies “A really useful guide that every SharePoint developer should have in their bookcase.” —Tomáš Herceg, Microsoft Visual Basic MVP “Carter, Scholl, and Jausovec have created an invaluable resource for profession- als who need to learn the new Visual Studio Tools for SharePoint. With great walkthroughs and thorough explanations, this book is required reading for every SharePoint developer.” —Scot Hillier, Microsoft SharePoint MVP, Scot Hillier Technical Solutions, LLC “If you’re a .NET developer looking for a book to help you quickly get up to speed then SharePoint 2010 Development with Visual Studio 2010 is the book. You won’t get stumped or overwhelmed. It is laid out in an easy to consume way that will get you developing SharePoint apps in no time!” —Joel Oleson, Senior Architect & Evangelist, Quest Software “The depth and insightful nature of Eric Carter’s writing has always been impres- sive. This book is no exception. Eric and coauthors Boris and Peterwere key members of the team that designed and built the SharePoint Developer Tools in Visual Studio 2010, giving them the uncanny ability to describe how and why these powerful new tools in Visual Studio 2010 work the way they do.” —Ted Pattison, Author and Instructor, Critical Path Training “From no-code, list-based approaches to service applications and back-end heavy lifting, SharePoint 2010 is a huge application, and an even larger devel- opment platform. If you are a SharePoint Developer, regardless of your level or experience with any current or previous SharePoint version, you should read this book in order to better understand your dizzying array of solution approaches. This is a valuable read thanks to in-depth guidance and insightful code samples.” —Matt Ranlett, MVP SharePoint Server “Carter, Scholl, and Jausovec certainly have the credentials for putting their names on the cover of this book. They’ve been deeply involved in shaping the developer platform and tools for SharePoint 2010 from its inception to release, and their experience and knowledge are shared across all 912 pages—a must have reference for professional developers writing solutions and features for SharePoint 2010, written by the people that built it.” —Richard Riley, Group Product Manager, SharePoint, Microsoft “I was delighted to review this quality manuscript straight from the Visual Stu- dio development team. As seen with Eric’s previous books, Eric, Boris, and Peter managed to create an excellent book not only to learn how to develop great solutions but also to use as a reference guide to explore the specifics of SharePoint 2010—a real gem to add to your developer book collection.” —Maarten van Stam, Microsoft MVP for VSTO, www.maartenvanstam.nl “This is the most indispensable resource for SharePoint 2010 development with Visual Studio by the team that built the tools.” —Andrew Whitechapel, Program Manager Architect, Microsoft SharePoint 2010 Development with Visual Studio 2010 Microsoft® .NET Development Series Visit informit.com/msdotnetseries for a complete list of available products. The award-winning Microsoft .NET Development Series was established in 2002 to provide professional developers with the most comprehensive, practical coverage of the latest .NET technologies. Authors in this series include Microsoft architects, MVPs, and other experts and leaders in the field of Microsoft development technologies. Each book provides developers with the vital information and critical insight they need to write highly effective applications. SharePoint 2010 Development with Visual Studio 2010 Eric Carter Boris Scholl Peter Jausovec Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • 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. Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions. 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 responsibility for errors or omis- sions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk pur- chases or special sales, which may include electronic versions and/or custom covers and con- tent particular to your business, training goals, marketing focus, and branding interests. 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: informit.com/aw Library of Congress Cataloging-in-Publication Data Carter, Eric. SharePoint 2010 development with Visual Studio 2010 / Eric Carter, Boris Scholl, Peter Jausovec. p. cm. Includes index. ISBN 978-0-321-71831-0 (pbk. : alk. paper) 1. Microsoft SharePoint (Electronic resource) 2. Intranets (Computer networks) 3. Web servers. 4. Microsoft Visual studio. I. Scholl, Boris. II. Jausovec, Peter. III. Title. TK5105.875.I6C367 2010 006.7—dc22 2010022236 Copyright © 2011 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 repro- duction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, 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-71831-0 ISBN-10: 0-321-71831-3 Text printed in the United States on recycled paper at Edwards Brothers in Ann Arbor, Michigan. First printing, August 2010 To my wife, Tamsyn, and our children, Jason, Hayley, Camilla, Rand, Elizabeth, and Miles —Eric Carter To my wife, Christina, and our son, Anton, who was born while I was working on the book —Boris Scholl To Nives and my family —Peter Jausovec This page intentionally left blank Contents at a Glance Contents xi Figures xvii Tables xxxv Foreword xxxix Preface xli Acknowledgments xliii About the Authors xlv 1 Introduction to SharePoint 1 2 Introduction to SharePoint Development in Visual Studio 2010 105 3 Introduction to the SharePoint Object Model 153 4 SharePoint Lists 231 5 SharePoint Event Receivers 317 6 Working with Business Data 361 7 SharePoint Content Types 457 8 SharePoint Workflow 525 9 SharePoint Web Parts 579 ix