Wednesday 7 September 2011

UIVersionConfigurationEnabled & UIVersion in Sharepoint 2010

If at some point you need to do migrations between Sharepoint 2007 and Sharepoint 2010 you will find yourself in a difficult position. Some users will ask you for the user interface and another ones will just love the new one.

This is where UIVersionConfigurationEnabled comes along. This small property belongs to the SPWeb object and it will allow you to swap between UI.

This is a typical example of this property:
You have a Microsoft Office Sharepoint Server 2007 site, you upgrade the site to Sharepoint Server 2010. You need to create a feature that prevents collection administrators from upgrading the user interface of the site to Sharepoint 2010, Which property should you use?: Answer: UIVersionConfigurationEnabled = false;

I am going to post two examples of how to swap UIs:

1- Activate the old WSS3 User Interface in Sharepoint 2010:

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

2- Activate the native Sharepoint 2010 UI.

using (SPSite siteCollection = new SPSite("http://xxxYOUR_SERVERxx"))
{
    SPWeb site = siteCollection.OpenWeb()
    {
        site.UIVersion = 4;
        site.UIVersionConfigurationEnabled = true;
        site.Update();
    }
}

You can always do it with PowerShell and it will look like this:

$site = Get-SPSite("http://xxxYOUR_SERVERxxx")
$web = $site.OpenWeb()
$web.UIVersion = 3
$web.Update()
$web.Dispose()
$site.Dispose()

No comments: