I would like to access a resource-file from ASP.NET page. I have a folder named "Resources" containing the file "WebResources.resx" on the same level as the page. The name of the public class in the generated WebResources.Designer.cs is also "WebResources" My page's name is "formulargenerator.aspx". Access from code-behind works perfectly. I can access in 2 ways:
ResourceManager rm = new ResourceManager(typeof(WebResources));
string val = rm.GetString("Key");
And
string val = WebResources.Key;
But how can I access from page directly if I don't like to rename the Resource-file? I have tried to use the folder App_LocalResources - no access. Only if the resource-file is named like the page does it work. How is the syntax to access a ressource? The code below doesn't work. Must/Can I import a namespace?
<asp:Label Text="<%$Resources: WebResources, Key%>"开发者_如何学运维; runat="server" />
You might want to take look at ASP.NET Web Page Resources Overview. Local resources are specific to a concrete aspx page and use a different naming convention than global application resources. The resource tag you are using is more-likely to work if using global resources.
精彩评论