Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Building Custom Content Types in Windows SharePoint Services 3.0
Collapse the table of content
Expand the table of content

Building Custom Content Types in Windows SharePoint Services 3.0

Windows SharePoint Services 3

Summary:  In Windows SharePoint Services, a content type is a reusable collection of settings that are applied to a certain category of content. Learn how to build a custom content type by using Microsoft Visual Studio 2005 Extensions for Windows SharePoint Services 3.0.

Visual How To

Applies to:  2007 Microsoft Office System, Windows SharePoint Services 3.0, Microsoft Visual Studio 2005 Extensions for Windows SharePoint Services 3.0

Joel Krist, iSoftStone

January 2008

Overview

Content types, a core concept used throughout the functionality and services offered in Windows SharePoint Services 3.0, are designed to help users organize their SharePoint content in a more meaningful way. A content type is a reusable collection of settings that are applied to a certain category of content. Content types enable the management of the metadata and behaviors of a document or item type in a centralized, reusable way.

Microsoft Visual Studio 2005 Extensions for Windows SharePoint Services 3.0 provides new support for creating custom SharePoint content types. This Visual How To illustrates how to build a custom content type for Windows SharePoint Services 3.0 by using Microsoft Visual Studio 2005 Extensions for Windows SharePoint Services 3.0.

Code It

To illustrate how to build a custom content type, this section walks through four key steps:

  1. Creating an empty SharePoint application project in Microsoft Visual Studio.

  2. Adding a SharePoint custom content type to the project.

  3. Editing the attributes and fields of the custom content type.

  4. Building and deploying the custom content type to a SharePoint site.

Creating an Empty SharePoint Application Project in Visual Studio 2005

To create an empty SharePoint application project in Visual Studio 2005, do the following:

  1. Start Visual Studio.

  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.

  3. In the Project Types pane, select Visual C# and then select the SharePoint category.

  4. In the Templates pane, select Empty. Specify a name and location for the project, and click OK. Visual Studio creates a new solution containing an empty project.

    Figure 1. Creating an empty SharePoint application project

    Creating an empty SharePoint application project

Adding a Custom Content Type to the Project

Visual Studio Extensions for Windows SharePoint Services 3.0 provides support for creating SharePoint custom content types. To add a custom content type to the empty project created previously, do the following:

  1. In the Visual Studio Solution Explorer, right-click the empty project created previously, point to Add, and click New Item. Visual Studio displays the Add New Item dialog box.

    Figure 2. Adding a custom content type

    Adding a custom content type
  2. In the Categories pane, expand the Visual C# Project Items node and then select the SharePoint category.

  3. In the Templates pane, select Content Type. Specify a name for the content type, and click Add. Visual Studio displays the Content Type Settings dialog box.

    Figure 3. Content type settings

    Content type settings
  4. Select a base content type, and specify whether to add the type with an event receiver. Select OK to add the new content type to the project.

Editing the Custom Content Type Attributes and Fields

Visual Studio adds two content type related XML files to the project: [ContentTypeName].xml and [ContentTypeName].Fields.xml. The [ContentTypeName].xml file contains markup that describes the content type—its ID, name, group, description, and references to the fields, or columns, associated with the content type. The [ContentTypeName].Fields.xml file contains markup that describes the fields, or columns, associated with the content type. Edit these files to change the default attributes of the content type and specify the columns it uses. For more information on the content type attributes used in the [ContentTypeName].xml file, refer to the Content Type Definition Schema. For more information about the field attributes that are used in the [ContentTypeName].Fields.xml file, refer to the Field Definition Schema.

Building and Deploying the Custom Content Type

The content type project is ready to be built and deployed. In Visual Studio, on the Build menu, click Deploy Solution. Visual Studio builds the assembly for the content type and generates the necessary configuration files for deployment of the solution. It then deploys the solution to the SharePoint site.

Figure 4. Building and deploying solution settings

Building and deploying solution

You can now test the new content type in SharePoint by associating the content type with a list or library of the appropriate type. For more information on how to associate a content type with a list or library, refer to Add an existing content type to a list or library on Microsoft Office Online.

Read It

This article illustrated how to build a custom content type in SharePoint Services 3.0 by using Microsoft Visual Studio 2005 Extensions for Windows SharePoint Services 3.0. The key steps include:

  1. Creating an empty SharePoint application project in Microsoft Visual Studio.

  2. Adding a SharePoint custom content type to the project.

  3. Editing the attributes and fields of the custom content type.

  4. Building and deploying the custom content type to a SharePoint site.

See It

Building Custom Content Types

Watch the Video

Length: 06:14 | File Size: 5.9 MB | Type: WMV

Explore It
Show:
© 2015 Microsoft