List of Listings – SharePoint 2010 Web Parts in Action

List of Listings

Chapter 1. Introducing SharePoint 2010 Web Parts

Listing 1.1. Hello World Web Part

Chapter 2. Using and configuring Web Parts in SharePoint 2010

Listing 2.1. Adding a Web Part zone to a page

Chapter 3. Building Web Parts with Visual Studio 2010

Listing 3.1. The default Web Part control description file for a Visual Web Part

Listing 3.2. Adding controls to the CreateChildControls method

Chapter 4. Building the user interface

Listing 4.1. A Web Part with view state

Listing 4.2. SaveViewState and LoadViewState preserves the default view state

Listing 4.3. Adding dynamic validation groups to a Visual Web Part

Listing 4.4. A TextBox control with two validator controls

Listing 4.5. The code-behind of the custom validated input control

Listing 4.6. SPGridView control and SPDataSource object used in a Visual Web Part

Listing 4.7. A Web Part with a custom CSS class

Listing 4.8. A themable CSS

Listing 4.9. Controls in a Web Part that’s enhanced for accessibility

Listing 4.10. A Web Part that has two custom verbs

Chapter 5. Making Web Parts customizable

Listing 5.1. The two configurable Web Part properties for the RSS Web Part

Listing 5.2. Building the interface of the RSS Web Part

Listing 5.3. Handling of missing or invalid values in a Web Part

Listing 5.4. Handling of invalid configuration in a static Web Part

Listing 5.5. Creation of the controls in the Editor Part

Listing 5.6. The SyncChanges method

Listing 5.7. The ApplyChanges method

Listing 5.8. Implementation of the IWebEditable interface

Listing 5.9. Event handlers and postbacks added to the Editor Part controls

Listing 5.10. Styling of the controls in the Editor Part

Listing 5.11. The definition of the Coordinate class

Listing 5.12. The Coordinate Web Part definition

Listing 5.13. The expandable Converter class for the Coordinate object

Listing 5.14. The CheckRuntimeRender method

Listing 5.15. The runtime filter control for selecting the target groups

Listing 5.16. The LoadPostData method

Listing 5.17. The feature event receiver for the runtime filter

Chapter 6. Web Part resources and localization

Listing 6.1. Adding resources using modules in a SharePoint feature

Listing 6.2. Adding an image to a Web Part using the server-relative URL

Listing 6.3. Adding a localized Label control to a Web Part

Listing 6.4. Using the ASP.NET resource syntax in a user control

Listing 6.5. Localizing a Web Parts control description file

Listing 6.6. Implementation of the localized Web Part property display name

Listing 6.7. Using the localized Web Part property attributes

Listing 6.8. Using correct parsing of culture-specific input

Chapter 7. Packaging, deployment, and security

Listing 7.1. Deactivation code to remove Web Parts from the gallery

Listing 7.2. Improved deactivation code for removing Web Parts from the gallery

Listing 7.3. Implementing the full-trust proxy operation arguments

Listing 7.4. Implementation of the full-trust proxy operation

Listing 7.5. Registration and unregistration of the full-trust proxy

Listing 7.6. Invoking the full-trust proxy from a Web Part

Listing 7.7. Custom CAS policies defined in the solution manifest

Listing 7.8. Using the UpgradeActions element

Listing 7.9. Using the FeatureUpgrading method

Listing 7.10. Upgrading a Web Part property

Chapter 8. Tools for troubleshooting and logging

Listing 8.1. Using the correlation id in custom error messages

Listing 8.2. A Web Part using monitored scopes

Listing 8.3. A custom scoped performance monitor

Chapter 9. Programming and caching for performance

Listing 9.1. Asynchronous task for fetching an RSS feed

Listing 9.2. An asynchronous Web Part that fetches an RSS feed

Listing 9.3. Web Part that displays all lists in a site and the number of items in each list

Listing 9.4. Implementation of caching for the list statistics Web Part

Chapter 10. Dynamic interfaces in Web Parts

Listing 10.1. Adding an UpdatePanel to the RSS Web Part

Listing 10.2. Modifying OnPreRender of the RSS Web Part

Listing 10.3. JavaScript with jQuery timer plug-in that updates the Web Part partially

Listing 10.4. Adding a status bar to the Web Part

Listing 10.5. OnLoad method that saves the RssFeedUrl property

Listing 10.6. JavaScript function that creates and shows a modal dialog window

Listing 10.7. The basic outline of a Ribbon extension

Listing 10.8. Adding a custom tab to the Ribbon

Listing 10.9. Defining a Ribbon group template

Listing 10.10. Creating a contextual group containing a Ribbon tab

Listing 10.11. Ribbon template with two layouts

Listing 10.12. The page component required for the contextual Web Part

Listing 10.13. The pageComponentFactory object

Listing 10.14. Implementing the IWebPartPageComponentProvider interface

Chapter 11. The Client Object Model and Silverlight Web Parts

Listing 11.1. Adding a Web Part to a page using the Client Object Model

Listing 11.2. Modifying Web Parts using the Client Object Model

Listing 11.3. Silverlight code using the Client Object Model to retrieve tasks

Listing 11.4. Elements.xml file provisioning the Silverlight application package

Listing 11.5. The element manifest that provisions the Silverlight Web Part

Listing 11.6. A custom Silverlight Web Part

Chapter 12. Making Web Parts mobile

Listing 12.1. A control adapter for the Task Count Web Part

Listing 12.2. Timer job definition that installs the control adapter

Listing 12.3. The Execute method of the timer job

Chapter 14. Connecting Web Parts

Listing 14.1. Transforming IWebPartField endpoint to IUrlConnection endpoint

Listing 14.2. A filter Web Part that uses the ITransformableFilterValues interface

Chapter 15. Building pages and dashboards

Listing 15.1. Three Web Part zones positioned using DIV elements and CSS

Listing 15.2. Declarative provisioning Web Parts on a page

Listing 15.3. Programmatically provisioning Web Parts on a page