Tuesday, January 25, 2011

Programmatically Changing the UI Version in SP2010

In SharePoint 2010, there is the concept of a UI Version and it has a value of 3 or 4. When you upgrade your existing site, it will leave you at Version 3 which looks just like WSS3. However, you have the capability to upgrade to the new SharePoint 2010 visualizations which is version 4. If the administrators have the options enabled, you can change your UI version using the UI itself. It provides the capability to run on Version 3 but get a preview of 4 and then ultimately they can convert to version 4 completely. However, you may want to do this programmatically or you may want to revert back to version 3 after you have turned off preview mode. This quick snippet of code is how you do it.

using (SPSite siteCollection = new SPSite("http://sp2010-server"))
{
SPWeb site = siteCollection.OpenWeb()
{
site.UIVersion = 3;
site.UIVersionConfigurationEnabled = true;
site.Update();
}
}


Sanjay Tiwari

No comments: