SharePoint 2010 - Current Variation / Variation Labels

If you're trying to develop a web part, which utilizes the variation title and doing so by accessing the variation labels lists in SharePoint 2010 and experiencing problems, give this function a try. I've written it to compare the accessible locales against that of the current web LCID.
public static string GetCurrentWebRegionLabel()
{
     string strLabel = "USEN";
 
     SPSecurity.RunWithElevatedPrivileges(
     delegate()
     {
          ReadOnlyCollection _variations = 
               Variations.Current.UserAccessibleLabels;
          strLabel = _variations.FirstOrDefault(m =>      
               m.Locale.Equals(SPContext.Current.Web.Locale.LCID.ToString()))
                    .Title.ToString();
     });
 
     return strLabel;
}

Comments

Popular posts from this blog

C# - ListView Item Spacing (Padding)

C# / SQL - Performing Distributed Transactions

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)