Share via


Building Block: Lists and Document Libraries

Applies to: SharePoint Foundation 2010

Microsoft SharePoint Foundation 2010 offers several APIs that you can use to work with lists. The following managed object models provide types and members that allow you to modify list properties and create and manage list templates and list items:

  • For code that operates on the server, the Microsoft.SharePoint namespace provides the core classes that represent a list. The Microsoft.SharePoint.Deployment namespace provides an API for migrating content between site collections.

  • For managed code that operates in the context of client-side Microsoft .NET 3.5 applications or Silverlight applications, the Microsoft.SharePoint.Client namespace provides a subset of the types and members available in the server object model.

  • For script that operates in the browser, the ECMAScript (JavaScript, JScript) object model of the SP namespace provides a subset of the types and members available in the server object model.

  • The Lists Web service provides methods for working remotely with lists.

You can use the SaveAsTemplate(String, String, String, Boolean) method in the server-side object model to save an existing SharePoint Foundation list as a list template, or use the SPListTemplate class and its collection class to manage list templates. The SPListTemplate class represents both custom list templates, which you create through the SaveAsTemplate(String, String, String, Boolean) method or save through the UI, and list definitions, which you install and activate as a Feature in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES directory.

A list schema has both a base type and a list template type. The SPBaseType enumeration identifies the following list base types:

  • Generic list type for most lists

  • Document library

  • Discussion board

  • Survey

  • Issue

  • Unspecified base type.

The SPListTemplateType enumeration identifies the default list template types in SharePoint Foundation, each of which is associated with a single list base type definition. The SPList class provides access to list properties common to all lists, but it is also possible for list template types to derive from a list base type. For example, you can cast a list object that represents a document library as an SPDocumentLibrary object to access properties that are specific to document libraries.

Microsoft Microsoft Business Connectivity Services (BCS) provides APIs for working with external lists. For information about Business Connectivity Services, see Building Block: External Content Types and External Lists.

Object Model for Lists and Document Libraries

The following classes in the server and client object models can be used to work with lists, list templates, and list items:

For information about working with lists in the server object model, see Working with List Objects and Collections and programming tasks included in Basic Object Model Tasks in SharePoint 2010. For information about working with lists in the client object models, see Data Retrieval Overview and programming tasks in Common Programming Tasks in the Managed Client Object Model.

XML Used for Lists and Document Libraries

A list definition is activated as a SharePoint Foundation Feature and has a Schema.xml file that contains the schema, although much of the view definition is provided through XSLT in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\XSL directory. List is the top-level element in the list schema, but the Configuration element in a site definition schema also contains a List element to include a specific list as part of Web sites that are created through the site definition. The List Instance Feature allows you to specify default data with which to provision a list type. For information about how to use Features, see Using Features in SharePoint Foundation. For an example that shows how to create a list definition Feature, see How to: Create a Custom List Definition.

Building Block: Files and Documents

Building Block: Alerts

Building Block: Columns and Field Types

Building Block: SharePoint 2010 Content Types

Building Block: Event Handling

Building Block: External Content Types and External Lists

Building Block: Features

Building Block: Queries and Views

More Information about Lists and Document Libraries

SharePoint List Data Model

How to: Create a Custom List Definition

How to: Add a Document Template, File Type, and Editing Application to a Site Definition

How to: Create a Custom Action Specific to a List

How to: Create an Event Handler Feature

Common Programming Tasks in the Managed Client Object Model

Basic Object Model Tasks in SharePoint 2010

Web Templates

Site Definitions and Configurations