views:

64

answers:

1

When I have the following in my ascx web control:

<asp:Literal runat="server" Text="<%$Resources:core,Description%>" />

I get this error: The resource object with key 'Description' was not found.

But when I change the Literal to:

<asp:Literal runat="server" Text="<%$Resources:wss,viewlsts_desc%>" />

The control renders just fine.

What's so special about the wss resource file? How can I use core?

Update:

I still don't know why, but it appears that resource files in 14\CONFIG\Resources are available, while files in 14\Resources are not.

+1  A: 

I highly recommend SharePoint Resources, Types, Use and Deployment post which explains differences between SharePoint resource types in great detail. It's about SharePoint 2007, but I think nothing has changed in this area (except for the fact that 14 is the new 12).

The provisioning resources are located in the 12 hive in ..\12\Resources. In WSS the default provisioning resource file is core.resx. This file is used in site definitions (one.xml) files, features, list definitions etc.

[...]

Nevertheless the provisioning resource files are not accessible from the ASP.NET web sites. This is where the run-time resources come to play. These files are used in vanilla ASP.NET sites and are located in the web application folder under ..\wss\VirtualDirectories[port]\App_GlobalResources. They are compiled automatically by the .Net framework in the Resources namespace. These resources are available in assemblies and directly in ASPX pages. To access them from the code use the strongly-typed notation Resources.[file prefix].[resource name]. In ASPX pages use the explicit expression <%$ Resources:[filename prefix,]resource-key %>. The default WSS resource file in this category, used by all WSS sites, is wss.resx.

Marek Grzenkowicz
Thanks for this. We want to use out of the box resource strings, but I had no idea that the 12/14 hive only comes into play at creation of the web application. What a mess. I guess it shows where localization ranks priority wise to the SharePoint team.
Rich Bennema
@Rich Bennema The resource files stored in the *[12/14 hive]\Resources* folder cannot be accessed directly, but you can use the `SPUtility.GetLocalizedString` method (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getlocalizedstring.aspx). Example: `SPUtility.GetLocalizedString("$Resources:" + key, "core", lcid)`
Marek Grzenkowicz