asp.net mvc - How to include a string in a razor statement -


is possible include string in razor statement?

for example, following code:

page.title = resources.homestrings_en.title; 

i like so:

var locale = "_en"; page.title = resources.homestrings + locale + .title; 

clearly, not compile, how can go doing this?

you use reflection. if homestrings property of resources instance, can try following :

propertyinfo property = resources.gettype().getproperty("homestrings" + locale); page.title = (property.getvalue(resources) type of homestrings).title; 

of course works attributes, methods, etc. make sure necessary tests: property != null, (... type of homestrings) != null,...


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -