Wrox Programmer to Programmer™Join the discussion @ p2p.wrox.com Beginning 2010 Development Steve Fox Fox $39.99 USA $47.99 CAN Programming .NET/C / Microsoft Office 2010 Put the power
Trang 1Wrox Programmer to Programmer™
Join the discussion @ p2p.wrox.com
Beginning
2010 Development
Steve Fox
Fox
$39.99 USA $47.99 CAN Programming (.NET/C) / Microsoft Office 2010
Put the power of
SharePoint 2010 into practice
wrox.com Programmer Forums
Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world
Code Downloads
Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use
Read More
Find articles, ebooks, sample chapters and tables of contents for hundreds of books, and more reference resources on programming topics that matter
to you
As a first-class platform that has evolved significantly since its
previous release, SharePoint 2010 now provides several advancements
for the developer (native Visual Studio tools support, services and
extensibility enhancements, and APIs), and many new capabilities
(improved data programmability, line-of-business interoperability,
and sandboxed solutions) With this authoritative guide, industry
veteran Steve Fox provides expert guidance on developing applications
as he walks you through the fundamentals of programming, explores
the developer toolset, and provides practical code examples to teach
you how to use many of SharePoint’s new developer features You’ll
quickly discover how SharePoint’s rich platform supports great
collaboration, extensibility, and interoperability.
Beginning SharePoint 2010 Development:
• Guides you through the creation of your first SharePoint 2010 application
• Addresses working with SharePoint 2010 sites, lists, and Web parts
• Describes developing SharePoint applications using SharePoint
Designer 2010
• Reviews standard and Visual Web parts, as well as data view Web parts
• Details integrating SharePoint with Microsoft® Office
• Explains how to secure your SharePoint 2010 applications
Steve Fox is a Technical Evangelist in the Developer Platform Evangelism group
at Microsoft He presents at many conferences and has written numerous articles
Wrox Beginning guides are crafted to make learning programming languages
and technologies easier than you think, providing a structured, tutorial format
that will guide you through all the techniques involved
Trang 2Get more out of
Wrox Online Library
Hundreds of our books are available online
through Books24x7.com
Wrox Blox
Download short informational pieces and code
to keep you up to date and out of trouble!
Join the Community
Sign up for our free monthly newsletter at newsletter.wrox.com
Browse
Ready for more Wrox? We have books and e-books available on NET, SQL Server, Java, XML, Visual Basic, C#/ C++, and much more!
Contact Us
We always like to get feedback from our readers Have a book idea?
Need community support? Let us know by e-mailing wrox-partnerwithus@wrox.com
Related Wrox Books
Beginning SharePoint 2010 Administration: Windows SharePoint Services 4 and Microsoft SharePoint Server 2010
978-0-470-59712-5Packed with step-by-step instructions, tips and tricks, and real-world examples, this book dives into the basics of how to install, manage, and administrate SharePoint 2010 in an effective and secure manner
Beginning SharePoint 2010: Building Team Solutions with SharePoint
978-0-470-61789-2
Beginning SharePoint 2010: Building Team Solutions with SharePoint provides you with extensive knowledge and expert advice,
empowering you to become a SharePoint champion within your organization
Beginning Microsoft SharePoint Designer 2010
978-0-470-64316-7Covering both the design and business applications of SharePoint Designer, this complete Wrox guide brings you thoroughly
up to speed on how to use SharePoint Designer in an enterprise
Professional SharePoint 2010 Administration
978-0-470-53333-8Written by a team of SharePoint experts, this book covers installation, upgrading, configuration, architecture and capacity planning, monitoring, backups, and disaster recovery
Professional SharePoint 2010 Branding and User Interface Design
978-0-470-58464-4SharePoint allows influence over key branding issues like site design, how the user interface affects site visitors’ experience, ease of use, and other branding topics This book, from a team of SharePoint branding experts, covers it all
Professional SharePoint 2010 Development
978-0-470-52942-3This comprehensive book shows readers how to build field-tested solutions and create custom content management applications
Professional Microsoft FAST Search: Customizing, Designing, and Deploying Search for SharePoint 2010 and Internet Servers
978-0-470-58466-8FAST is Microsoft’s intelligent search-based technology that boasts an ability to integrate business intelligence with Search This guide provides you with advanced coverage on FAST search and shows you how to use it to plan, customize, and deploy your search solution, with an emphasis on SharePoint 2010 and Internet-based search solutions
Real World SharePoint 2010: Indispensable Experiences from 20 SharePoint MVPs
978-0-470-59713-2Containing contributions from nearly a score of SharePoint MVPs, this book is an anthology of best practices for all areas
of SharePoint 2010
Trang 3⊲ I GEttING StartED WIth SharEPoINt 2010 DEVELoPMENt
SharePoint 2010 Developer Tools
Building and Deploying SharePoint
chaPtEr 6 Web Parts 217
Creating Your First SharePoint 2010 Application
chaPtEr 7 .249
Part II
⊲ I aDVaNcED toPIcS for SharEPoINt 2010 DEVELoPMENt
Integrating Line-of-Business Data Using
Trang 4584637ffirs.indd 2 5/3/10 10:41:36 AM
Trang 5Beginning
SharePoint ® 2010 Development
Trang 6584637ffirs.indd 4 5/3/10 10:41:36 AM
Trang 7Beginning
SharePoint ® 2010 Development
Steve Fox
Trang 8Beginning SharePoint ® 2010 Development
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 6011, fax (201)
748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations 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
pro-motional 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 organization or Web site 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 information the organization or Web site may provide or recommendations it may make Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared 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 (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available
in electronic books.
Library of Congress Control Number: 2010926824
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other
coun-tries, and may not be used without written permission SharePoint is a registered trademark of Microsoft Corporation
in the United States and/or other countries 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.
Trang 9For my wife
Trang 10584637ffirs.indd 8 5/3/10 10:41:36 AM
Trang 11aBout thE author
StEVE fox of Redmond, WA, is a Senior Technical Evangelist in the Developer Platform Evangelism group at Microsoft He’s worked in the IT industry for more than 15 years, and has worked in the areas of natural language, search, developer tools, and, more recently, Office Business Application and SharePoint development Fox also presents at both domestic and international conferences (such as TechEd, PDC, DevConnections, and SAP TechEd, among others), and has written a number of books
such as Professional SharePoint 2007 Development using Silverlight 2 (Indianapolis: Wiley, 2009) and Microsoft NET and SAP (Redmond, WA: Microsoft Press, 2009), as well as articles for MSDN
Magazine and other technical magazines.
Trang 12584637ffirs.indd 10 5/3/10 10:41:36 AM
Trang 13aBout thE tEchNIcaL EDItorS
DarrIN BIShoP is a speaker, author, and developer focusing on Microsoft SharePoint Technologies
He is the president and lead developer for Darrin Bishop Group, Inc., a Midwest-based Microsoft
Partner focusing on SharePoint Technologies, portals, and collaboration He is the author of The
Rational Guide to Building SharePoint Web Parts (Greenland, N.H: Rational Press, 2008), as well
as several articles in various magazines Bishop is an international speaker and speaks at many SharePoint conferences, SharePoint Saturdays, MOSS Camps, and User Groups He has been work-ing with SharePoint Technologies since the release of SharePoint Portal Server 2001
ELI roBILLarD designs and guides the delivery of global SharePoint solutions as a Principal Architect at Infusion Development Corporation He is a SharePoint Server MVP, a co-author of
Professional SharePoint 2007 Development (Indianapolis: Wiley, 2007), founder of the Toronto
SharePoint Users Group, co-chair of the Toronto SharePoint Camp, and past chair of a group of high-profile industry influencers and early-adopters known as the ASPInsiders Robillard lives in Toronto, Ontario, Canada where he also plays music and goes on adventures with Dawn, Irina, and their dog, Dakota
KENNEth SchaEfEr is an independent developer and designer focusing on SharePoint and based solutions
Web-BrENDoN SchWartz has worked in the Atlanta area User Group scene, and is known around town as one of the Atlanta NET Regular Guys (www.devcow.com) He is currently on the INETA Board of Directors as the Vice President of Technology, and is a Microsoft MVP for ASP.NET
Today, Brendon works to solve real-world business problems with Microsoft technologies, such as SharePoint, Office, BizTalk, VSTS, and NET technologies In addition to presenting at local User Groups, he helped create the “Free Training 1,2,3!” series (www.freetraining123.com) to help developers learn Microsoft technologies He presented material at the first SharePoint 1,2,3! event (www.sharepoint123.com), along with other members of the Atlanta Microsoft Professionals
Schwartz has helped on the leadership teams of five different User Groups At the first Atlanta Code Camp in 2005, he presented material on ASP.NET mobile controls
Trang 14584637ffirs.indd 12 5/3/10 10:41:36 AM
Trang 15Mary Beth Wakefield
aSSocIatE DIrEctor of MarKEtING
Trang 16584637ffirs.indd 14 5/3/10 10:41:37 AM
Trang 17WhEN It coMES to WrItING a BooK, no man is an island It takes countless hours and resources to compile a book of this nature That said, I’d like to thank Jim Minatel and Paul Reese for taking on the project, and to Kevin Shafer for marshaling the book through the editorial and review process
A number of technical editors helped review chapters, so a big thanks to Darrin, Eli, Ken, and Brendan The comments were great and helped create a better end product They also taught me a few things along the way
I’d also like to say a blanket thanks to all of the content and production editors All of you made the book possible and, at the end of the day, a much better product for the beginning SharePoint developer
On a personal note, I’d like to thank my wife who put up with me locking myself away for hours at
a time Nicole, you are ever-tolerant and I’m deeply indebted to you
Trang 18584637ffirs.indd 16 5/3/10 10:41:37 AM
Trang 19SharePoint 2010: The Platform 12
SharePoint Central Administration 19
Installing and Configuring Windows Server Hyper-V 37
Getting Familiar with SharePoint 2010 45
Trang 20Developing SharePoint Applications Using SharePoint Designer 2010 78
Managing Other Data Sources in SharePoint Designer 85
Creating Web Parts 130
Creating Lists, Site Columns, and Content Types 135 Working with SharePoint Data 141 Creating Event Receivers 147 Creating aspx Pages 150 Creating Master Pages 153
Trang 21CONTENTS
Programming Against Lists Using the Client Object Model 186Programming Against Lists Using a Custom WCF Service 197
Creating Event Receivers for a SharePoint List 210
Understanding Office Business Applications (OBAs) 278
Anatomy of an External Content Type 284 Connectivity Options with BCS 287 Developing Your First Application Using BCS 289
Trang 22CONTENTS
ASP.NET Web Services 365
WCF Web Services 378 RESTful Web Services 387 Azure and SharePoint 390
Recommended Reading 398
inteGratinG sharePoint ChaPter 11:
Content Type as a Document Template 400 Using InfoPath in Your SharePoint Solutions 404 Managing Office Documents through a SharePoint Workflow 406 Integrating Office Documents with SharePoint List Data 410 Server-Side Services 418
Trang 23CONTENTS
seCurinG your ChaPter 12:
Trang 24584637flast.indd 22 5/2/10 7:11:44 PM
Trang 25My fIrst experIence wIth sharepoInt was the task of integrating multiple SharePoint 2003 sites into one all-up organizational portal — a fairly straightforward project that integrated four sites into one This one project got me curious, and, in the process, not only exposed me to the inner workings of SharePoint, but also got me hooked on the technology
As I learned more about SharePoint, I realized the path was longer than I had originally thought Since that time, I’ve seen the platform mature quite a bit, and interest from developers like yourself swell to what is now a very high rate of growth and adoption And the market for SharePoint is also growing at
a very rapid pace — one that is currently outpacing the growth of the SharePoint developer community What you’ll learn in this book is that SharePoint 2010 has a lot to offer the developer You can move from the small-scale development project where you’re building custom Web parts, to the larger, enterprise-grade solution that leverages Web services and integrates with other Microsoft and non-Microsoft technologies This is the incredible part about SharePoint — it is a platform with huge potential in multiple directions And, as a beginning SharePoint developer, you should strap yourself
in, because you’re in for a great ride
who thIs Book Is for
Simply put, this book is aimed at the developer who is new to SharePoint The book assumes that you have some programming experience and a passion to learn how to develop for SharePoint But this book does not assume that you’ve programmed against SharePoint before If this somewhat fits with you, then this book is absolutely for you
With regard to your general development background, the two assumptions in this book are that you have some familiarity with Web development, and you have an understanding of NET pro-gramming With regard to Web development, this book assumes that you understand HTML, and may have an understanding of Cascading Style Sheets (CSS), Extensible Markup Language/
Extensible Stylesheet Language (XML/XSL), and dynamic languages such as JavaScript You may have a light understanding of ASP.NET and are looking to apply this knowledge to the SharePoint space In any case, you have some understanding of the fundamentals of Web and NET develop-ment, and are looking to apply those to the SharePoint space
what thIs Book covers
SharePoint 2010 is a significant leap forward from the 2007 release, and you will find that there are
a ton of features built into the platform for you to leverage in your solution development Because SharePoint is a broad platform that covers a lot, this book also covers quite a bit of ground surface
As a Wrox Beginning book, the goal of the book is to get you started with many of the
fundamen-tals so that you can continue on to advanced programming beyond this book