Change new button order and default content type
Programmatically set the New button order for a Document Library
Suppose you have a document Library contains the following content Types.
· Project Folder
· Sub Project Folder
Project Folder derived from Folder content type.
Sub Project Folder derived from Project Folder
Below that you have allow the user to Creates a document.
But if three content types are attached to document library, then in New Button it will come like this.
Here we have another ‘new’ option ‘Folder’. To remove follow this.
Settings àDocument Library Settings àAdvanced Settings
Set ‘No’ to Display “New Folder” command on the New menu? option.
Now the menu will look like this
But our requirement
§ If you are in the Root level only Project Folder needs to come.
§ If you are inside the Project Folder only Sub Project Folder menu has to come.
§ If you are inside the Sub Project folder then only document menu has to come.
Something like this.
Check my previous post here to set this default content type.
How to set programmatically
Here for the Document Library root folder we set Project Folder as default
SPList myList = Web.Lists[“MyProjects”];
if (myList != null)
//Remove the ‘Folder’ menu item from the New Menu option
myList.EnableFolderCreation = false;
SPContentTypeCollection oContentTypes = myList.ContentTypes;
SPFolder rootFolder = myList.RootFolder;
SPContentType orderedContentTypes = new SPContentType;
foreach (SPContentType oContentType in oContentTypes)
if (oContentType.Name == “Project Folder“)
orderedContentTypes = oContentType;
rootFolder.UniqueContentTypeOrder = orderedContentTypes;
Now create an Item Event Receiver. In the ItemAdded event check the current content type of the added item. Based on that, assign next level new menu option, to the created folder.