Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Access External Resources from Website Aspx

My current solution consists of several Class Libraries and a Website. I'm in the process of globalizing the application and I realized that my resources need to be accessed by all the projects not just the website so placing my resources in the App_GlobalResources folder didn't work.

I added my resources to one my class Libraries and now I'm trying to figure out what the best way of accessing the resources are from my markup. When my resources were in the App_GlobalResources folder I was able to access them by using an expression such as this:

<$ Resources: MyApp.Name %>  for server controls

Or

<%=Resources.MyApp.Name %> for plain text

What's the best way of accessing my Resources from my website aspx files now that they are in a Class Library DLL?

Thanks for your help!

like image 349
mga911 Avatar asked Feb 26 '10 02:02

mga911


1 Answers

I found a great article which discusses Extending the Resource-Provider Model. It allows for the use of expressions to access external resources:

The syntax for a $Resources expression for the default provider model (explicit global resources) is the following.

<%$ Resources: [resourceType], [resourceKey] %>

The same expression can be used to access external resources when the ExternalResourceProviderFactory is configured, with the following syntax change.

<%$ Resources: [assemblyName]|[resourceType], [resourceKey] %>

For example, to retrieve a resource from the CommonResources.dll assembly, from the global resource type "CommonTerms", you would use the following explicit expression.

<asp:Label ID="labGlobalResource" runat="server" Text="<%$ Resources:CommonResources|CommonTerms, Hello %>" ></asp:Label>
like image 70
mga911 Avatar answered Sep 23 '22 07:09

mga911