I'm looking to use App_LocalResources in my MVC Application, but I'm wondering about a solid implementation.
My idea is to loop through the Resx file and grab all of the Keys. The store those keys in an object from the ViewModel.
Then in my View, I can use <%: model.resources.key %>
to extract the information.
Do any of you guys know how I can efficiently extract all of the values of a Resource file and dump them into an Object in the ViewModel? Is this even possible?
EDIT:
I have discovered how to get a single record out of the Resx file, just not the whole thing.
Dim whats_next = HttpContext.GetLocalResourceObject("~/views/about/faq.aspx", "whats_next").ToString
ViewData("whats_next") = whats_next
Return View()
What I need to be able to do is this (where the ViewModel.Resources Object is just a List(Of KeyValuePairs)
)
Dim ViewModel As Domain.FAQViewModel = New Domain.FAQViewModel()
ViewModel.Resources = ''# enumerate APPROPRIATE LOCAL resource file and store all keys
Return View(ViewModel)
From here, I can extract all of the keys in my view
<%: model.Resources.ResourceKey1 %><br />
<%: model.Resources.ResourceKey2 %>