How to hide content type choice control in edit forms

If you want the edit form of a particular list to don’t show some field, you can change the ContentType definition by setting ShowInEditForm=”FALSE” in corresponding FieldRef element.

If you want to do the same with Content Type field, the above hint simply don’t work.

To make it working you have to modify the rendering template of the edit form. To do this you have to create a new rendering template:

  1. copy the standard ListForm template from DefaultTemplates.ascx (ControlTemplate folder)

  2. create a new ascx file in the same folder and paste ListForm template

  3. change the template id to MyCustomForm

  4. remove the Sharepoint ContentTypeChoice control from the custom template

Then you have to associate the edit form to the custom template created above, to do this you can modify the content type definition inserting XmlDocuments tag under ContentType tag like in the following example:


If you don’t have content type you can change the list definition schema by using the following code:

Form Type="DisplayForm"
WebPartZoneID="Main" />
Form Type="EditForm"
WebPartZoneID="Main" />
Form Type="NewForm"
WebPartZoneID="Main" />


Technorati Tag: ,

Comments (13)
  1. Vadim Dzyuban says:

    Hi Dario,

    It is very interesting topic but I’m not so clear with everything. Does your solution require to modify/change

    the 12TEMPLATECONTROLTEMPLATESDefaultTemplates.ascx file or create a new one (with new name) based of this file (steps 1-3 in your post) ?

    I’ve created a feature with site columns, content type (MyContentType inherited from Document content type) and document library (MyDocLib) and deployed it. All are CAML based. Then while uploading a file into doc lib, in edit and view mode the Content Type choice/drop-down box appears with two choices – Document and MyContentType. I need to Hide this choice/drop-down box and MyContentType must be used by default while loading documents into MyDocLib library.

    Could you please explain your solution in more detail. I’m new to SharePoint.


    Vadim Dzyuban

  2. Hi Vadim,

    probably you only need to delete the reference to the Document CT from your library definition schema to show only one entry in the dropdown list.

    If you want to hide the dropdown list you can follow the steps in my post. You have to create a new .ascx file (ex. MyCustomForm.ascx) in the 12TEMPLATECONTROLTEMPLATES folder (or subfolder) because is not a best practice to modify sharepoint files and also, most important, it’s not supported by Microsoft.


  3. Vadim Dzyuban says:

    Hello Dario,

    Here are the steps I’ve followed:

    1. I’ve created new MyCustomForm.ascx (by opening the 12TEMPLATECONTROLTEMPLATESDefaultTemplates.ascx file and saving it as MyCustomForm.ascx). So, I have a newly created file as well as the original file.

    2. Inside new MyCustomForm.ascx file I’ve removed the <td valign="top" class="ms-formbody"><asp:DropDownList ID="ContentTypeChoice" ToolTip="<%$Resources:wss,form_content_type%>" runat="server"/><br> tag

    3. I’ve modified the content type definition inserting XmlDocuments tag under ContentType tag as  you suggested.  

    After deployment, activation the feature, going to my doc lib and uploading a file then in the Edit mode I’m getting an empty rendered area.

    Am I missing something in steps 1-3 above ?



  4. Hi Vadim,

    in your custom .ascx file you need only te ListForm template and not all the templates included in DefaultTemplates.ascx.

    You have also to change the template id to MyCustomForm (or whatelse you want) and use the same id in XmlDocuments code. The template id is the reference key.



  5. Vadim Dzyuban says:

    Hi Dario,

    1. I’ve created new MyCustomForm.ascx in the 12TEMPLATECONTROLTEMPLATES folder from DefaultTemplates.ascx. 2. Inside this new file I left just one rendering template with ID="ListForm" and then renamed it to ID="MyCustomForm" 3. I used the same name "MyCustomForm" in XmlDocuments code. 4. I deployed and activated my feature, went to my doc lib, uploaded a file.

    Unfortunately the drop-down content type choice box still has been rendered and visible (not hidden) in Edit form/mode as well.

    Any idea ? Did anyone did this implementation ?



  6. Hi Vadim,

    have you re-created the doclib after deploying new features?

  7. Vadim Dzyuban says:

    Yes, I did. In my feature: I create my site columns, my content type (inherited from Document), add my site columns to my content type, create my doc lib and bind it to my content type. All are CAML based (no C# code).

    What I need after the feature will be deployed is while a user loads a document then (1) the choice (drop-down) control should not be visible (rendered) at all and (2) my content type (not Document content type) with the my site columns should be in use (as a default content type).

    Following the above advise I’ve created MyCustomForm.ascx from 12TEMPLATECONTROLTEMPLATESMyCustomForm.ascx as follows. Inside MyCustomForm.ascx I removed everything except the lines with "<%@ … " at the beginning of file and the section with "<SharePoint:RenderingTemplate ID="ListForm" … </SharePoint:RenderingTemplate>

    , then I renamed section ID="ListForm" to ID="MyCustomForm".

    Is this correct ?

    I need to hide the choice (drop-down) control of content types even the default content type will be the Document from which I inherited my content type. I can try to setup my content type as a default content type via c#.

  8. Your problem is that Document is the default CT of the doclib.

    In the schema of your list definition you have to specify only your custom content type. If you don’t have a custom list definition (and you don’t want to create it) you have to write some code to specify the default (and probably only) CT.


  9. Vadim Dzyuban says:

    You’re right Dario, and this can be done as explained in the Ton Stegeman’s post via C# at Following his advise and implementing code below then the choice (drop-down) box of content types is not showing up at all (it is like hidden)

    SPContentType listCt1 = list.ContentTypes["MyContentType"];

           SPContentType listCt2 = list.ContentTypes["Document"];

    SPFolder folder = list.RootFolder;

           SPContentType[] orderedContentTypes = new SPContentType[1];

           orderedContentTypes[0] = listCt1;

           folder.UniqueContentTypeOrder = orderedContentTypes;


    Thank you anyway for your feedback, patience and help. I’m still with my question, am I correctly created MyCustomForm.ascx file (see above)… something missing in that process of hiding choice control via xml/CAML ?



  10. RG says:

    Great Info Dario. Thanks for the fix.

  11. McThrustin says:

    You don’t need to add the entry into the DefaultTemplates.ascx file, you can create a seperate file with your definition inside it, as long as it’s in the same folder.  This will keep the original file unmolested and allows for some portability of code to different servers.

  12. You are absolutely right McThrustin!

    I didn’t write about pasting new template to DefaultTemplates.ascx but I agree with you that it can be misunderstood. I will soon update the article.

  13. jeff.barton says:

    Any ideas on doing the opposite with custom list forms?  I.e. I need to add the option to change a content type from a DataFormWebPart.  I’ve tried adding a SharePoint control that points to the ContentType field, but noticed that the onchange event that exists in the ListFormWebPart does not exist for this control.  I tried setting that event via javascript, and although it matched perfectly it still didn’t work.  The LFWP handles content type switches by doing a call to STSNavigate and setting the ContentTypeId param in the query string, but the DFWP doesn’t know how to handle this param and just errors out.

    I am currently fumbling through creating a replacement "OK" button, hoping to set the content type of the item based on the value in the Content Type control, but I keep getting a ThreadAbortException which I can’t seem to get past.  Any ideas would be greatly appreciated.

Comments are closed.

Skip to main content