Localizing ASP markup in webpart issue
-
06-12-2019 - |
Pregunta
In my web part I have an label, which I want to be localized:
<asp:Label ID="AppJSTNameLabel" runat="server" Text="<%$Resources:AppListWebPart,NoSelection%>" />
I have mapped Resources
folder and created there files: AppListWebPart.resx
and AppListWebPart.pl-PL.resx
.
Both resource files contain NoSelection key with appropriate translations, but every time I deploy and test my web part, I'm getting:
Parser Error Message: The resource object with key 'NoSelection' was not found.
This drives me crazy. Any idea what I might be doing wrong?
Solución
When adding resources
to mapped Resource
folder you are placing resx files to <hive>\xx\Resources\
folder and your web part cannot access them.
Proper place for this kind of resource is IIS application App_GlobalResources
folder (x:\Inetpub\wwwroot\wss\VirtualDirectories\<port>\App_GlobalResources\
).
Fore more info you can read SharePoint Internals: Resources (a bit old but it covers your issue).
If you are using 2010 with VS 2010 then you just add Module
item to your project, delete all files included by default, put your resx inside it and use item properties on resx item to set Deployment Type : AppGlobalResource
For 2007 you can use: SharePoint Resources, Types, Use and Deployment