开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜