In addition I created a function to retrieve the resources that read the resx file if available. If the resourcefile is obsolete (Not published to the App_GlobalResources with ststadm -o copyappbincontent or a feature receiver) The resource will be created from the default resource compiled into the assembly.
Code:
public static String GetResource(String ID)
{
String ResourceString = "";
// Check if the resource exists in the App_Resources folder
// Hint use stsadm -o copyappbincontent to copy the contents from the /CONFIG/Resources directory
// A better way to update the resources is by a feature receiveres
try
{
ResourceString = HttpContext.GetGlobalResourceObject("chandrila_cdlf", ID, SPContext.Current.Web.Locale).ToString();
}
catch
{ }
try
{
if (String.IsNullOrEmpty(ResourceString))
{
// Fall back to the compiled resources
return Resources.chandrila_cdlf.ResourceManager.GetString(ID);
}
else
return ResourceString;
}
catch
{
// If all fails return the ID of the resource that was requested.
return ID;
}
}
Not rocket science, but it helps avoiding strange errors for the SharePoint Adminstrators
No comments:
Post a Comment