Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

As we know, different versions of SharePoint has different looks, so, in WebPart development, I will output different css to fit specific version of SharePoint. I did it like this:

int majorSPVersion = SPFarm.Local.BuildVersion.Major;
if (majorSPVersion = 12)
{
    // output css for SharePoint 2007
}
else if (majorSPVersion = 14)
{
    // output css for SharePoint 2010
}  

But this solution can not handle SharePoint 2013, because SharePoint 2013 has two user experience, and majorSPVersion returns 15 in both user experience. So, how to check user experience version in SharePoint 2013? I want do it like this:

if (majorSPVersion = 12)
{
    // output css for SharePoint 2007
}
else if (majorSPVersion = 14)
{
    // output css for SharePoint 2010
}  
else if (majorSPVersion = 15)
{
    if (2010 user experience)
    {
        // output css for 2010 user experience
    } 
    else if (2013 user experience)
    {
        // output css for 2013 user experience
    } 
}  

Is it possible? Thanks in advance.

share|improve this question
    
My tip would be to check out one of sharepoints pages that you can find in the 15 hive. There should be some example markup that you can use for example in your .ascx file to send out different css files –  Robert Lindgren May 9 '13 at 7:28
    
@RobertLindgren Thanks for your tip. And I also found that we can use SPWeb.UIVersion to check it. –  Xiaodan Mao May 10 '13 at 4:23

1 Answer 1

up vote 1 down vote accepted

Since individual sites can run different versions of the UI, the check would not be done based on the farm properties, but rather something site level, so you may need a subsequent check within the v15 block. To be clear though, SharePoint 2010 offered the same option, so it is still possible that you have a v14 farm that is using the SharePoint 2007 UI.

share|improve this answer
1  
Thanks. I followed your tips and searched about how to use SharePoint 2007 UI in SharePoint 2010, then I found I can use SPWeb.UIVersion to get the version number. –  Xiaodan Mao May 10 '13 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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