Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Business users don't want to show the content type when a user goes to the list/doc lib and clicks on new drop down. I used contypeType.Hidden = true; but it did not work.

http://www.novolocus.com/2009/05/26/control-the-content-types-in-the-new-menu-via-code/

Any other idea?

share|improve this question
    
What content type are you trying to hide? An OOB one? Custom? How was the custom one created? –  Tim Gabrhel May 20 '11 at 19:59
    
are you talking about New Form or about drop down list with CTs to create before a New Form appear? –  Ivan Padabed May 20 '11 at 20:48
    
Note that as the referenced article mentions, setting hidden will remove it from the new menu, but not the Content Type drop down on the edit form. That may be adequate (but it's not how I'd describe 'hidden'!) –  Andy Burns May 23 '11 at 8:58
add comment

2 Answers

up vote 1 down vote accepted

Here is the code that works.

SPContentType oCT = spList.ContentTypes[ctName];
oCT.Hidden = true;
oCT.Update();
share|improve this answer
    
What is different about this code versus what you did the first time? Did you forget to run the .Update() method? –  Tim Gabrhel May 20 '11 at 20:00
    
@Tim: I had reinstantiate spcontenttype and this time with splist. First time i had to user web.availablecontenttype to associate a specific ct with my splist. then i could hide the custom ct use the code posted. Thanks –  Roxanne May 20 '11 at 20:04
    
@SiteOwner: R u serious? I have to wait 2 days before I can accept my own answer. Is this by design or bug? –  Roxanne May 20 '11 at 20:05
    
it's by design. –  PirateEric May 23 '11 at 1:19
add comment

Did you call the Update method after setting the Hidden property?

contentType.Hidden = true;
contentType.Update();
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.