views:

54

answers:

1

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 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.

A: 

you could use GetGlobalResourceObject

so something like

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