39,59 €
Microsoft SharePoint 2010, is the best-in-class platform for content management and collaboration. With the combined capabilities of Sharepoint and Visual Studio, developers have an end-to-end business solutions development IDE. To leverage this powerful combination of tools it is necessary to understand the different building blocks. This book will provide necessary concepts and present ways to develop complex business solutions and take them further.SharePoint 2010 Development Cookbook With Visual Studio 2010 is an instructional guide for developing and debugging applications for SharePoint 2010 environment using Visual Studio 2010. The cookbook approach helps you to dip into any recipe that interests you, you can also read it from cover to cover if you want to get hands on with the complete application development cycle.With this book you will learn to develop event handlers, workflows, content types, web parts, client object model applications, and web services for SharePoint 2010 in an instructional manner. You will discover the less known facts behind debugging feature receivers, deployment of web parts, utilizing free toolkits to enhance the development and debugging experience. You will learn the newer development approach called Visual Web Parts, how to develop and deploy Silverlight applications that can be used with Silverlight web part. You will also explore SandBoxed deployment model and its usage. You will create your own web services for SharePoint and the Client Object Model introduced in SharePoint 2010. All in all, you will develop Sharepoint solutions in an instructional manner that eases the learning process.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 299
Veröffentlichungsjahr: 2011
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2011
Production Reference: 1190911
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-458-3
www.packtpub.com
Cover Image by Sandeep Babu (<[email protected]>)
Author
Balaji Kithiganahalli
Reviewers
Wei Chung Low
Michael Nemtsev
Doug Ortiz
Acquisition Editor
Dhwani Devater
Development Editor
Hithesh Uchil
Technical Editor
Prashant Macha
Project Coordinator
Shubhanjan Chatterjee
Proofreader
Lisa Brady
Indexer
Tejal Daruwale
Graphics
Nilesh Mohite
Production Coordinator
Melwyn Dsa
Cover Work
Melwyn Dsa
BalajiKithiganahalli has been a computer nerd since 1995. He has a Master's degree in Systems Engineering and is currently serving as CEO and partner for Integrate, LLC. His company specializes in systems integration and custom software development. He has over 15 years of software development and architectural experience. He has consulted with several government and multi-national clients.
He is a technology agnostic who used to mainly work on J2EE related technologies. Since 2003, he is mainly involved in implementing SharePoint and .NET technologies. He is currently architecting SharePoint 2010 implementation for a very large government organization in Atlanta, GA.
When not working, he enjoys going for bike rides with his kids and reading books about other technologies. He currently lives in Atlanta, GA with his beautiful wife and two kids.
Every journey begins with a first step; this is true in my case as it is my first book. This journey of mine would not have been successful if it was not for the support of my family and many of my friends. I am truly blessed with such wonderful family and friends.
First and foremost, I'd like to thank my mom, dad, and brother for their wonderful support and encouragement in every step of the way and providing moral support when needed. I would also like to thank my lovely wife Vanishree and kids Veda and Amit for their patience, support, and understanding without which I would have never been able to complete this book. Next, I would like to thank my technical reviewers. You guys did an awesome job. Your insight and input has increased the overall value of this book.
I would also like to thank my publisher Packt Publishing, and the many fine people such as Dhwani, Shubhanjan, Hithesh, and Prashant for their valuable input and patience. You guys ROCK! I guess I owe you guys a beer when you are here in Atlanta.
Writing a book is a lot of work and is time-consuming. Even though I am the only author on this book, there are many people who are involved in making this book a finished product for the readers. While I may not come in contact with many of these folks, I would like to thank them and certainly appreciate their work and effort.
Wei Chung, Low a Technical Lead in BizTalk and .NET and a MCT, MCPD, MCITP, MCTS, MCSD.NET, works with ResMed (NYSE: RMD), at its Kuala Lumpur, Malaysia campus. He is also a member of PMI, certified as a PMP. He started working on Microsoft .NET in his early career and has been involved in development, consultation, and corporate training in the area here of business intelligence, system integration, and virtualization. He previously worked for the Bursa Malaysia (formerly Kuala Lumpur Stock Exchange) and Shell IT International, which provided him with rich integration experience across different platforms.
He strongly believes that great system implementation delivers precious value to business, and the integration of various systems across different platforms shall always be a part of it. Just like how people from different cultures and diversities are used to living together in most of the major cities, in harmony.
DougOrtiz is an independent consultant whose skillset encompasses multiple platforms such as .Net, SharePoint, Office, and SQL server.
He possesses a Master's degree in Relational Databases and has over 20 years of experience in Information Technology. Of those years of experience, half are within .Net and SharePoint. His roles have ranged from Architecture, Implementation, Administration, Disaster Recovery, Migrations, Development, and Automation of Information Systems; in and outside of SharePoint.
He is the founder of Illustris, LLC and can be reached at: <[email protected]>.
Interesting aspects of his profession:
His hobbies include Yoga and Scuba Diving.
I would like to thank my wonderful wife Mila for all her help and support as well as Maria and Nikolay.
I would also like to thank everyone at Packt Publishing for their encouragement and guidance.
Michael Nemtsev is an ex-Microsoft MVP in .NET/C# and SharePoint Server 2010 and has held that status between the years 2005 and 2011.
Michael's expertize are in Enterprise Integration and Platform and Collaboration areas and currently he is working as a Senior Consultant at Microsoft in Sydney, Australia helping clients to improve business collaboration with SharePoint 2010 and Office365.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read, and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
Microsoft SharePoint 2010 is the best-in-class platform for content management and collaboration. With Visual Studio, developers have an end-to-end business solutions development IDE. To leverage this powerful combination of tools it is necessary to understand the different building blocks of SharePoint. This book will provide necessary concepts and present ways to develop complex business solutions and take them further.
SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook is an instructional guide for developing, debugging and deploying applications for SharePoint 2010 environment using Visual Studio 2010. The cookbook approach helps you to dip into any recipe that interests you or you can also read it from cover to cover if you want to get hands on with the complete application development cycle.
With this book you will learn to develop event handlers, workflows, content types, web parts, client object model applications, and web services for SharePoint 2010 in an instructional manner. You will discover the less known facts behind debugging feature receivers, deployment of web parts, utilizing free toolkits to enhance the development and debugging experience.
You will learn the newer development approach called Visual Web Parts and how to develop and deploy Silverlight applications that can be used with Silverlight web parts. You will also explore the SandBoxed deployment model and its usage. You will create your own web services for SharePoint and learn more about the Client Object Model introduced in SharePoint 2010. All in all, you will develop SharePoint solutions in an instructional manner that eases the learning process.
Chapter 1, List and Event Receivers: Event Receivers are used for responding to events raised by SharePoint on lists, features, list items, and so on. This chapter not only provides an overview of the event receivers that can be developed using Visual Studio 2010, but also guides you through the step-by-step process of creating them and applying them to real world scenarios.
Chapter 2, Workflows: In this chapter, you will learn about sequential workflows, site workflows, and deploying custom initiation forms with workflows using ASPX pages and InfoPath forms. You will also learn to create custom InfoPath task forms with the workflows.
Chapter 3, Advanced Workflows:In this chapter, you will learn Advanced Workflow topics such as creating custom activity for both sandboxed and non-sandboxed environments. You will not only learn how to create state machine workflows but also to model them. This chapter also guides you through the process of creating a Pluggable workflow service. Last but not least, this chapter also guides you through the process of changing workflow statuses.
Chapter 4, List Definitions and Content Types: In this chapter, we will discover the world of content types. We will use object models to create content types, add new columns, document templates, and workflows to content types using Visual Studio 2010. This chapter also guides you through the process of creating external content types that are linked to external data source such as the SQL Server database. In the end of the chapter, we will also learn how to create list definitions using Visual Studio.
Chapter 5, Web Parts: In this chapter, we will discover visual web parts, code-only web parts, AJAX enabled web parts, and Silverlight web parts. The chapter also provides details on connectable web parts and adding configuration properties to web parts. This chapter also provides detailed information on versioning and deployment of web parts.
Chapter 6, Web Services and REST: In this chapter, we will learn about using REST services to extract data from SharePoint. We will create client applications that make use of REST to extract data from SharePoint. We will also learn to create custom SharePoint WCF web services.
Chapter 7, Working with Client Object Model: SharePoint 2010 introduced the new Client Object Model which can be used to create client applications that use SharePoint as a backend data store. In this chapter, we will learn all the three client object models such as the managed object model, the JavaScript object model, and the Silverlight object model. We will also learn the exception handling techniques and asynchronous calling of these object models.
This book presents a series of projects that demonstrates the features of SharePoint 2010 and Visual Studio 2010. In order to gain hands on experience of these features, it is recommended that you have a 64-bit Windows development machine with lots of memory. Chapter 1, List and Event Receivers of this book provides the list of software and links that you can refer to set up your development environment. If you do not have a license for this software, you can always get the trial version from the Microsoft website.
Alternatively, you can read through this book without working through the projects. There are plenty of screenshots that provide a good sense of how these solutions work. This is not a suitable approach for beginner programmers.
This book is for .NET developers to understand the building blocks of SharePoint 2010. Although the book can be used by beginners, it is recommended that the readers have an understanding of the previous versions of SharePoint. Developing SharePoint solutions requires solid understanding of ASP.NET architecture. The book assumes that the reader is familiar with ASP.NET technology and development concepts.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "We can include other contexts through the use of the include directive."
A block of code is set as follows:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Select File | New | Project. The new project wizard dialog box as shown will be displayed (Make sure to select .NET Framework 3.5 in the top drop-down box)".
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, we will cover:
SharePoint 2010 has a very robust event handling capability that can be used for custom pre and post list event processing. When you create your custom event receivers, you are writing event handlers for different events that SharePoint fires due to an action. The main events triggered by SharePoint can be classified as follows:
The preceding events are triggered by SharePoint when changes, creations, or deletions happen on different objects like Lists, Sites, Site Collections, List Items, and so on.
All the events listed previously can be further classified as, Synchronous and Asynchronous events. Synchronous events are those that are fired before an action takes place (for example, the ItemAdding event or the ItemDeleting event on a List Item). Synchronous events are executed on the same thread as the code, before sending the response to the browser. Asynchronous events are those that take place after the action has happened for example, the FeatureActivated event or FeatureInstalled event on Features.
For example, a Synchronous event ItemAdded on list item can be used to verify the data that is being added to a list before it gets added. This way you have control over the data that gets added and if needed, you can cancel the data getting added to the list. You cannot cancel an Asynchronous event. Asynchronous events are used for business process flow like sending an e-mail after the item gets added to the list.
Typical scenarios that include creating event handlers are as follows:
The custom event receiver you write will be packaged as a solution file (with .wsp extension) to deploy to SharePoint event host. Every event receiver is bound to some SharePoint object which is also its host. Site, Web, List, Features, and so on are some of the examples of the hosts. In the previous versions of the Visual Studio, there were no out-of-the-box templates that supported SharePoint development. You had to manually create your manifest files and feature.xml files and use MakeCab.exe for creating your solution files to deploy. The other alternative was to use open source tools like WSPBuilder for making life a little easier. However, this is not the case with Visual Studio 2010. There are templates available for Event Receivers, Workflows, List Definitions, Visual Web Parts, and many more. We will work with many of them in the subsequent chapters.
Do not use event handlers for long running processes. Use Workflows for that purpose. We will handle Workflows in Chapter 2, Workflows.
Feature receivers like List Event Receivers are handlers that you write when certain events happen from Features. In the Feature Event Receivers, you can write custom handlers when events like Feature Installation, Feature Activation, Feature Deactivation, or Feature Uninstall happens.
Feature Event Receivers are used when you, as a programmer, needs to create entries in web.config for database access or if you are a product vendor, then activate license files, and so on when a Feature is installed or activated. You can also use event receivers for clean-up activities like removing an entry from web.config or delete a list, and so on when a Feature is removed or deactivated.
