ASP.NET: Localization: Get .resx value in MVC view using dynamic key
I have a view, and in this view, I need to get a value from an 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 don't want 开发者_C百科to get into a discussion about separation of concerns and all that. I just want to know how to use Resources (ResourceManager)? to write out a .resx value using a dynamic key for an entry in a App_GlobalResources file.
you could use GetGlobalResourceObject
so something like
(String)GetGlobalResourceObject(
"IndexView", keyRoot + Model.BlahBlah)
精彩评论