Once I received this question from one of my customer’s who probably hadn’t dabbled much with SharePoint OM :

“I’ve created my own document library definition in which I removed the default Document content type, and added my own document content type, called MyDocument.

After I activated my feature, the document library works fine and it uses MyDocument as the default content type. However, I would like to hide the “New MyDocument” menu and only allows user to use upload button to upload documents. Is this doable ?

I found that even if I set Hidden=True inside my custom content type definition, it still appears under the New menu because it’s the default content type. Any idea how to hide this from the New menu.”

Doable? Yes sir .. it is ..

So, although the Library has a custom content type (default), but we since we don’t want the option to have it under “New” menu –we are looking to achieve what is shown below :

clip_image002[13]

If one tries to do it through UI i.e, Document Library Settings-> Change New Button Order and Default Content Type one gets this :

clip_image004

So, we write below code to achieve what’s shown in first picture above :

<Code Sample>
 
SPSite ss = new SPSite("http://mosssite/");
SPWeb ww = ss.OpenWeb();
SPList list4 = ww.Lists["DocLibTest2"];
list4.ContentTypes["MyDocument"].Hidden = true;
list4.ContentTypes["MyDocument"].Update();
 
</Code Sample>

Not a cool thing though,if we have to run this code everytime the custom Document Library is created. I haven’t yet figured out how to integrate it with the custom Document Library itself, or Automatically have this code run, each time the custom DocLib is created. Will post if I find a better way!!