ASP.NET: Localization: get .resx value in MVC view using dynamic key

I have a view, and in this view I need to get the value from the App_GlobalResources file using a dynamic key.

Normally, for example, I would do this:

<%= Resources.IndexView.MyKey %>

However, in this case I need to do something like:

<%= Resources.IndexView[keyRoot + Model.BlahBlah] %>

I do not want to discuss the separation of problems and all that. I just want to know how to use resources (ResourceManager)? to write the .resx value using a dynamic key to write to the App_GlobalResources file.

+3
source share
1 answer

you can use GetGlobalResourceObject

so something like

(String)GetGlobalResourceObject(
            "IndexView", keyRoot + Model.BlahBlah)
+4
source

Source: https://habr.com/ru/post/1767060/


All Articles