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

Tài liệu SharePoint 2010 Web Parts in Action ppt
Nội dung xem thử
Mô tả chi tiết
MANNING
Wictor Wilén
IN ACTION
www.it-ebooks.info
SharePoint 2010 Web Parts in Action
www.it-ebooks.info
www.it-ebooks.info
SharePoint 2010
Web Parts in Action
WICTOR WILÉN
MANNING
Greenwich
(74° w. long.)
www.it-ebooks.info
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
180 Broad Street, Suite 1323
Stamford, CT 06901
Email: [email protected]
©2011 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.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15 percent recycled and processed without the use of elemental
chlorine.
Manning Publications Co. Development editor: Susan Harkins
180 Broad Street, Suite 1323 Copyeditor: Liz Welch
Stamford, CT 06901 Typesetter: Gordan Salinovic
Cover designer: Marija Tudor
ISBN 9781935182771
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 16 15 14 13 12 11
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
To my amazing wife and our two beautiful daughters
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
vii
brief contents
PART 1 INTRODUCING SHAREPOINT 2010 WEB PARTS . ....................1
1 ■ Introducing SharePoint 2010 Web Parts 3
2 ■ Using and configuring Web Parts in SharePoint 2010 24
PART 2 DEVELOPING SHAREPOINT 2010 WEB PARTS......................53
3 ■ Building Web Parts with Visual Studio 2010 55
4 ■ Building the user interface 79
5 ■ Making Web Parts customizable 110
6 ■ Web Part resources and localization 148
7 ■ Packaging, deployment, and security 171
8 ■ Tools for troubleshooting and logging 201
9 ■ Programming and caching for performance 221
10 ■ Dynamic interfaces in Web Parts 242
11 ■ The Client Object Model and Silverlight Web Parts 274
12 ■ Making Web Parts mobile 291
13 ■ Design patterns and testability 309
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
viii BRIEF CONTENTS
PART 3 DASHBOARDS AND CONNECTIONS .....................................333
14 ■ Connecting Web Parts 335
15 ■ Building pages and dashboards 359
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
ix
contents
preface xvii
acknowledgments xviii
about this book xx
about the cover illustration xxiii
about Web Parts xxiv
PART 1 INTRODUCING SHAREPOINT 2010 WEB PARTS..........1
1 Introducing SharePoint 2010 Web Parts 3
1.1 What is a Web Part? 5
1.2 Why use Web Parts? 7
1.3 Introducing the Web Part infrastructure 9
Web Part page 9 ■ Web Part Manager 10 ■ Web Part
zones 10 ■ Web Part elements 12 ■ Web Part Gallery 12
1.4 Types of Web Parts 12
ASP.NET 2 Web Parts 13 ■ SharePoint Web Parts 14
Changes in the Web Part infrastructure for SharePoint 2010 15
1.5 Hello World example 16
1.6 SharePoint 2010 pages 17
Application pages 18 ■ Site Pages 18 ■ Master pages 22
1.7 Summary 22
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
x CONTENTS
2 Using and configuring Web Parts in SharePoint 2010 24
2.1 The SharePoint 2010 user interface 25
The new SharePoint user interface and the Ribbon 25 ■ Other
interface improvements 26
2.2 The Web Part Gallery 27
What is the Web Part Gallery? 28 ■ Uploading or adding new Web Parts
to the gallery 29 ■ Editing Web Parts in the gallery 29 ■ Grouping the
Web Parts 30 ■ Permissions on Web Parts in the gallery 30
2.3 Out-of-the-box Web Parts 31
SharePoint Foundation 2010 31 ■ SharePoint Server 2010 33
2.4 Working with Web Parts and pages 38
Creating a page using the web interface 38 ■ Adding Web Parts
using the web interface 39 ■ Filtering a Web Part using Web Part
connections 41
2.5 Customizing and personalizing pages 42
Shared view 43 ■ Personal view 43 ■ Closing and deleting Web
Parts 44 ■ Maintenance view 44
2.6 SharePoint Designer 2010 45
Adding Web Parts to a page 46 ■ Adding a Web Part using
SharePoint Designer 2010 47 ■ Configuring Web Parts using
SharePoint Designer 2010 47 ■ Adding pages 48 ■ Editing
pages and adding zones 48 ■ Import and export of solutions using
SharePoint Designer 49
2.7 Exporting and importing Web Parts 49
Exporting a Web Part 50 ■ Importing a Web Part 50
Prohibiting the export of a Web Part 51
2.8 Summary 51
PART 2 DEVELOPING SHAREPOINT 2010 WEB PARTS .........53
3 Building Web Parts with Visual Studio 2010 55
3.1 Requirements for your development environment 56
3.2 Developing for SharePoint 2010 in Visual Studio 2010 57
3.3 Building your first Visual Web Part 59
The Visual Web Part template 60 ■ The SharePoint Customization
wizard 61 ■ Explore the SharePoint Project Items 62 ■ Adding
functionality to your Visual Web Part 65 ■ Build and deploy the
Visual Web Part 67 ■ Take your Web Part for a test drive 69
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
CONTENTS xi
3.4 Traditional Web Part projects 70
Create an empty SharePoint project 71 ■ Adding the Web Part to the
project 71 ■ Adding controls to the Web Part 73 ■ Adding the buttonclick event manually 74 ■ Testing and debugging your Web Part 74
3.5 Upgrading SharePoint 2007 projects 75
Upgrading from Visual Studio Extension for WSS 1.3 75
Upgrading from other project types 75
3.6 SharePoint Project settings in Visual Studio 76
3.7 SharePoint Server Explorer in Visual Studio 77
3.8 Extensibility in Visual Studio 2010 78
3.9 Summary 78
4 Building the user interface 79
4.1 ASP.NET and Web Parts 80
Adding controls to the Web Part 80 ■ The event flow for a Web
Part 81 ■ Working with view state 85 ■ Using validators 87
Custom controls and user controls 89
4.2 SharePoint controls 92
Default SharePoint controls in Visual Studio 92 ■ Standard
SharePoint controls 93
4.3 Look and feel of Web Parts 97
CSS in SharePoint 97 ■ Custom style sheets 99 ■ SharePoint
themes 102 ■ Web compliancy 104 ■ Web Part icons 105
4.4 Web Part verbs 106
Adding verbs to a Web Part 107 ■ Event flow when using Web Part
verbs 108
4.5 Summary 109
5 Making Web Parts customizable 110
5.1 Web Part properties 111
Adding a property 111 ■ Customizing the property 114 ■ Custom
categories 115 ■ Default values on properties 116 ■ Properties used in
the Web Part class and defined in SharePoint 119 ■ Properties in Visual
Web Parts 119 ■ Personalization 120 ■ Storing URLs in Web Part
properties 121 ■ Static Web Parts 121 ■ Web Part
previews 122 ■ Error handling in Web Part properties 122
5.2 Common Web Part properties 123
Appearance properties 123 ■ Layout properties 124
Advanced properties 124
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
xii CONTENTS
5.3 Custom Editor Parts 126
Create a custom Editor Part 127 ■ Add the custom Editor Part to the Web
Part 128 ■ Validating properties 130 ■ Property dependencies 131
Visual appearance of the Editor Part interface 133
5.4 Advanced properties 135
Define the property 136 ■ Problems with complex types 137
Create a type converter 137
5.5 Runtime filters 140
The AuthorizationFilter property 140 ■ Create a runtime filter 141
Create the user filter control 143 ■ Register the runtime filter 145
Use the filter 146 ■ Overriding the default Target Audiences
filter 147
5.6 Summary 147
6 Web Part resources and localization 148
6.1 Linking and embedding resources 149
Using the SharePoint root folders 149 ■ Using class resources 151
Embedded resources 153 ■ Resources in SharePoint libraries 155
URL Expression Builder in SharePoint 2010 Server 156
6.2 Localization resources in Web Parts 157
Localization methods 157 ■ Localizing code 159 ■ Localizing
Visual Web Part user controls 160 ■ Localizing the Feature 161
Localizing the Web Parts control description file 162 ■ Localizing
Web Part properties 163 ■ Localizing using satellite
assemblies 165 ■ Localizing style sheets, scripts, and images 167
Other localization considerations 169
6.3 Summary 170
7 Packaging, deployment, and security 171
7.1 Solution packages 172
Windows SharePoint package files 172 ■ SharePoint Features 173
Safe controls and the RequiresDesignerPermission attribute 178
7.2 Deployment and activation 180
Solution deployment using PowerShell 180 ■ Feature activation
and deactivation 183
7.3 Sandboxed solutions 184
What is sandboxing? 185 ■ Configuring the sandbox 186
Deploying and installing sandboxed solutions 187 ■ Full-trust
proxies 187
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
CONTENTS xiii
7.4 Web application targeted solutions 190
Building solutions for web application deployment 190 ■ Code
Access Security policies 192 ■ Custom CAS policies 192
7.5 Upgrading solutions 194
How to upgrade 195 ■ Upgrading Features 195 ■ Assembly
redirection 197 ■ Upgrading Web Parts 198
7.6 Summary 200
8 Tools for troubleshooting and logging 201
8.1 Logging and error handling in SharePoint 2010 202
Introducing the correlation id 203 ■ SharePoint trace logs 204
Searching the trace logs 205 ■ Custom logging to trace logs 206
Error handling in sandboxed solutions 207
8.2 Debugging Web Parts with Visual Studio 2010 208
Attaching to processes 208 ■ Debugging sandboxed
solutions 209 ■ Debugging feature receivers 210
8.3 The Developer Dashboard 210
Enabling the Developer Dashboard 210 ■ Using the Developer
Dashboard 211 ■ Using monitored scopes 212 ■ Logging using
scoped performance monitors 213 ■ Custom logging to the
Developer Dashboard 215
8.4 Custom error handling 215
8.5 Other debugging tools 217
ASP.NET tracing 218 ■ Internet Explorer Developer Tools or
Firebug 219 ■ Fiddler web proxy 219
8.6 Summary 220
9 Programming and caching for performance 221
9.1 Programming for performance 222
Computational performance 222 ■ Object and memory
usage 222 ■ Scalability 222 ■ Perceived performance 223
9.2 Programming for performance in SharePoint 223
Proper handling of SharePoint objects 224 ■ Make smarter queries
to SharePoint 225 ■ Asynchronous operations 227 ■ Improve
performance of resources 230
9.3 Caching techniques 232
ASP.NET caching 233 ■ Caching objects and structures 235
Caching resources 238
9.4 Summary 241
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info
xiv CONTENTS
10 Dynamic interfaces in Web Parts 242
10.1 Using Ajax and JavaScript in Web Parts 243
Working with Microsoft ASP.NET AJAX Extensions 243
JavaScripts in Web Parts 246 ■ Working with jQuery 248
10.2 Using the SharePoint dynamic UI features 251
Notification messages and the status bar 251 ■ The dialog
framework 254
10.3 Enabling a Web Part to use the Ribbon 258
Adding controls to the Ribbon 258 ■ Making a Web Part context
aware 263
10.4 Summary 273
11 The Client Object Model and Silverlight Web Parts 274
11.1 The Client Object Model 275
What is the ECMAScript Client Object Model? 275 ■ Working
with the Client Object Model and Web Parts 276
11.2 Silverlight Web Parts 279
SharePoint Silverlight Web Part 279 ■ Building a Silverlight SharePoint application 280 ■ Input parameters to the Silverlight Web
Part 283 ■ Packaging the Silverlight Web Part 284 ■ Preconfiguring
the Silverlight Web Part 286 ■ Custom Silverlight Web Part 287
Enabling custom Silverlight Web Part interaction with SharePoint 289
11.3 Summary 290
12 Making Web Parts mobile 291
12.1 SharePoint 2010 mobile interface 292
Using the mobile SharePoint 2010 interface 292 ■ Page, form, and
Web Part support 293 ■ Supported mobile Web Parts 294
Supported devices 294 ■ Browser definition files 295
12.2 Mobile Web Part adapters 296
Create a mobile adapter 297 ■ Register a mobile adapter 299
12.3 Mobile controls 305
12.4 Summary 307
13 Design patterns and testability 309
13.1 Design patterns 310
What are design patterns? 310 ■ Loose coupling 311
Dependency injection 312
Download from Wow! eBook <www.wowebook.com>
www.it-ebooks.info