This documentation is archived and is not being maintained.

SPBuiltInContentTypeId Class

Windows SharePoint Services 3

A class that retrieves SPContentTypeId objects that represent identifiers (IDs) for built-in content types.

System.Object
  Microsoft.SharePoint.SPBuiltInContentTypeId

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPBuiltInContentTypeId
'Usage
Dim instance As SPBuiltInContentTypeId

You can use the fields of this class in a way that is similar to the way that you use members of an enumeration.

The following example shows a console application that finds both the common parent of two content type IDs and the name of the parent content type. It also prints the result to the console.

Imports System
Imports Microsoft.SharePoint

Module Test
   Sub Main()
      Using site As SPSite = New SPSite("http://localhost")
         Using web As SPWeb = site.OpenWeb()

            Dim x As SPContentTypeId = SPBuiltInContentTypeId.Message
            Dim y As SPContentTypeId = SPBuiltInContentTypeId.Discussion

            ' Get the parent content type ID.
            Dim parentId As SPContentTypeId = SPContentTypeId.FindCommonParent(x, y)

            ' Get the parent content type name.
            Dim ct As SPContentType = web.AvailableContentTypes(parentId)
            Dim parentName As String = ct.Name

            ' Display the result.
            Console.WriteLine("ID of Message is       {0}", x.ToString())
            Console.WriteLine("ID of Discussion is    {0}", y.ToString())
            Console.WriteLine("Their common parent is {0} ({1})", _
                              parentId.ToString(), parentName)

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module

The application prints the following output to the console.

ID of Message is       0x0107
ID of Discussion is    0x012002
Their common parent is 0x01 (Item)

Press ENTER to continue...

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: