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" />
Kind regards in advance
Navigate resources in the editor Open a . resx file in the XML (Text) editor. Press Alt+\ or choose ReSharper | Navigate | Go to File Member… from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With