We have a partial view which renders a <ul>
containing <li>
items that represent menu items. These are currently static in structure, and handle multilingual with resource files as follows:
<li><a href="@Url.Action("commissionlist", "commissions")">@Resources.Labels.Commissions</a></li>
However, I need to dynamically build the menu structure. So I have a list of menu item objects, which each have a MenuResourceTag field.
How do I get from having a string representing the name of the property I need to look up (e.g. "Commissions") to accessing the value of the appropriate property on Resources.Labels?
I know the answer will involve reflection, but all the examples I've found of similar things require an instance of the Resources.Labels class, and I can't work out how to get it in Razor.
Aucun commentaire:
Enregistrer un commentaire