Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
SPContentType Class
 Hidden Property

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
SPContentType.Hidden Property (Microsoft.SharePoint)
Gets or sets whether the content type is hidden on the list’s New menu.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
Public Property Hidden As Boolean
Visual Basic (Usage)
Dim instance As SPContentType
Dim value As Boolean

value = instance.Hidden

instance.Hidden = value
C#
public bool Hidden { get; set; }

Property Value

true if the content type is hidden on the list’s New menu; otherwise false.
Exception typeCondition

SPContentTypeReadOnlyException

The value of the ReadOnly property is true.

SPContentTypeSealedException

The value of the Sealed property is true.

You can use this property to specify that a content type be hidden. Hidden content types are not displayed on the New menu for list views. Therefore, users cannot create new items of that content type from the list. The content type is still displayed everywhere else in the user interface.

TipTip:

To change the order in which content types appear on the New menu, set the UniqueContentTypeOrder property.

When you modify the value of this property, your change does not take effect until you call the Update method. Calling this method commits all modifications to the content type definition back to the SharePoint database.

The following console application prevents one of the content types available in a document library from appearing on the library’s New menu.

Visual Basic
Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Console.WriteLine()

        Dim oSPSite As SPSite = New SPSite("http://localhost")
        Dim oSPWeb As SPWeb = oSPSite.OpenWeb()

        ' Hide a content type from the New menu on a list.
        Dim oList As SPList = oSPWeb.Lists("Custom Document Library")
        Dim oContentType As SPContentType = oList.ContentTypes("Content Type Name")
        If (oContentType.ReadOnly Or oContentType.Sealed) Then
            Console.WriteLine("Content type cannot be modified.")
        Else
            oContentType.Hidden = True
            oContentType.Update()
            Console.WriteLine("Content type is now hidden.")
        End If

        oSPWeb.Dispose()
        oSPSite.Dispose()

        Console.WriteLine()
        Console.Write("Press ENTER to continue...")
        Console.ReadLine()
    End Sub

End Module
C#
using System;
using Microsoft.SharePoint;

namespace Test
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            Console.WriteLine();
            SPSite oSPSite = new SPSite("http://localhost");
            SPWeb oSPWeb = oSPSite.OpenWeb();

            // Hide a content type from the New menu on a list.
            SPList oList = oSPWeb.Lists["Custom Document Library"];
            SPContentType oContentType = oList.ContentTypes["Content Type Name"];
            if (oContentType.ReadOnly || oContentType.Sealed)
            {
                Console.WriteLine("Content type cannot be modified.");
            }
            else
            {
                oContentType.Hidden = true;
                oContentType.Update();
                Console.WriteLine("Content type is now hidden.");
            }

            oSPWeb.Dispose();
            oSPSite.Dispose();

            Console.WriteLine();
            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}
Community Content   What is Community Content?
Add new content RSS  Annotations
Does not work      PaulB   |   Edit   |   Show History
It's unclear what this property is supposed to do, but change this does not hide a content type from a list, nor is the content type hidden in the content type list.
Tags What's this?: Add a tag
Flag as ContentBug
Hiding the content type in the New menu      Mudava   |   Edit   |   Show History
Reflector show that SPContentType.Hidden is used by Microsoft.SharePoint.WebControls.NewMenu.AddMenuItems() and it does hide the Content Type in the New menu. Just wait for WSS to push down the changes.
Tags What's this?: Add a tag
Flag as ContentBug
This property can not be propagated to child content types and lists via the Update(true) method      Todd Walker   |   Edit   |   Show History
Unlike other properties such as the ReadOnly property, changes to the Hidden property do not get propagated when you use the Update(true) method. This is probably why the Hidden property is not even available in the web interface for creating/modifying site content types. You have to manually propagate these changes to this property by calling the Update() method on each site content type list content type instance.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker