Programmatically Changing the UI Version in SP2010
Posted
Tuesday, November 24, 2009 9:59 AM
by
CoreyRoth
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();
}
}
Here, we are using the new UIVersion property and we are reverting back to Version 3. I’m also enabled the Version Configuration in the User Interface.