Hide content types of a list in share point programmatically.(Hide the content types in new button drop down in the share point list)
//hide the content types of a list in the new button drop down list private static void HideContentType(SPList list) { string contentTypeName = string .Empty; SPContentType contentType; Console.WriteLine( "enter the name of the content type to hide" ); contentTypeName = Console.ReadLine(); if (! string .IsNullOrEmpty(contentTypeName)) { contentType = list.ContentTypes[contentTypeName]; if (contentType != null ) { contentType.Hidden = true ; Console.WriteLine( "content type of the list is hiden" ); } else { Console.WriteLine( "content type is not exists for the current list" ); } } else { Console.WriteLine( "content type name should not be null or empty" ); } } |
In the above code take content type what we need to hide as input. Then check the list if the list have the content type or not. If the list contains the content type then make hidden property of the content type as true.
Hope this will help you.
Comments