I have a lot of local resourse files
- /Controls/App_LocalResources/SomeControl.ascx.resx,
- /Pages/App_LocalResources/SomePage.aspx.resx, etc.
I want to add another language and I do not want to go through all folders and add SomeControl.ascx.de.resx files for example and then have to recompile the whole think.
I would like to use satellite assemblies and embed all the files into something like MyWebPage.de.dll
This was possible in VS2003 version for global resources, but I'm not sure can I do it in VS200开发者_StackOverflow8 version for local resources?
I am accessing the resource with the syntax:
<asp:label id="lblSomething" runat="server" meta:resourcekey="labelFirstName"/>
Your question isn't really too clear on whether you are looking for a feature of VS2008 or a feature of the ASP.NET framework. So I'll go with the code solution.
The implicit binding syntax you're using uses ASP.NET's default LocalResourceProvider which takes in the path of page under which the resources live to work out which resources to load. If your resources are stored elsewhere and you still want to use the implicit binding systax in your code in front you'll need to use your own Provider. Sounds complicated but it's fairly straightforward.
To do this you'll need to first subclass ResourceProviderFactory
and override both
IResourceProvider CreateGlobalResourceProvider(string classKey)
IResourceProvider CreateLocalResourceProvider(string virtualPath)
...then implement your own IResourceProvider that gets your resources from your satellite assemblies using a ResourceManager
public interface IResourceProvider
{
object GetObject(string resourceKey, CultureInfo culture);
IResourceReader ResourceReader { get; }
}
You then need to add configuration to your web.config file to let ASP.NET know to use your SatelliteResourceProviderFactory and move your resources in to your external assemby, but that should be you good to go.
Plenty of documentation can be found here...under the "Building a Database Resource Provider" section...
http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4
精彩评论