In the UI I can drill down into a ContentType settings -> Document Information Panel settings -> and set 'Show Always' to true (marking the check box).

How do i set this option through code? (or in a contenttype defition in a feature)


This information is stored as an XmlDocument in the Content Type. The SPContentType has a property called XmlDocuments which is a collection of XmlDocument objects. You can get the Xml containing the info like this;:

string xml = contentType.XmlDocuments["http://schemas.microsoft.com/office/2006/metadata/customXsn"];

This string contains Xml. For the DIP you should check the /customXsn/openByDefault element. A value of True means that the DIP is shown, empty or False will not show it.

To modify this you have to retrieve the Xml, change the value, remove the current XmlDocument from the content type and add your newly constructed xml and finally update it. Like this:

string schema = "http://schemas.microsoft.com/office/2006/metadata/customXsn";
// load old settings
string xml = contentType.XmlDocuments[schema];
// load it in an Xml Document
XmlDocument doc = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
// get the DIP info node
XmlNode node = doc.SelectSingleNode("/xsn:customXsn/xsn:openByDefault", nsmgr);
// Set it to true
node.InnerText = bool.TrueString;
// delete the old one
// add the new xml
// update the CT
| improve this answer | |
  • Did not know that. Good stuff Wictor. – Charles Lee Mar 11 '10 at 14:32
  • Yea, isn't SP beautiful - there are so much stuff to learn and find out. That's why I'm still love my work! – Wictor Wilen MCA MCM MVP Mar 11 '10 at 14:44
  • 1
    To 'Love' SP is a little strong... :o) It is more a love-hate relationship. – trgraglia Aug 6 '12 at 12:29

In the meantime i found the 'feature definition' solution (thanks to SharePoint Manager). Add the following XML to the ContentType definition in the elements file:

  <XmlDocument NamespaceURI="http://schemas.microsoft.com/office/2006/metadata/customXsn">
    <customXsn xmlns="http://schemas.microsoft.com/office/2006/metadata/customXsn">
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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