2010-09-30 64 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

相關問題