2010-09-30 55 views
4

当我在我的ASCX Web控件如下:

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

我得到这个错误:与主要的“描述”资源未找到对象。

但是,当我更改文字到:

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

控件呈现就好了。

wss资源文件有什么特别之处?我如何使用核心?

更新:

我仍然不知道为什么,但它出现在14个\ CONFIG \资源与资源文件可用,而在14个\资源文件都没有。

回答

5

我强烈建议SharePoint Resources, Types, Use and Deployment这篇文章详细解释了SharePoint资源类型之间的差异。这是关于SharePoint 2007,但我认为这方面没有任何改变(除了是新的)。

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.

+1

感谢您的支持。我们希望使用开箱即用的资源字符串,但我不知道12/14配置单元仅在创建Web应用程序时发挥作用。真是一团糟。我想它显示了本地化对SharePoint团队的优先考虑。 – 2010-10-01 13:46:49

+1

@Rich Bennema存储在* [12/14 hive] \ Resources *文件夹中的资源文件无法直接访问,但可以使用'SPUtility.GetLocalizedString'方法(http://msdn.microsoft.com/zh-cn/我们/库/ microsoft.sharepoint.utilities.sputility.getlocalizedstring.aspx)。例如:'SPUtility.GetLocalizedString(“$ Resources:”+ key,“core”,lcid)' – 2010-10-01 15:19:33

相关问题