c# - How to render anonymous model in Razor View? -


the main purpose use anonymous class pass data containing various values outside main model view without having create separate viewmodel.

i found myself comfortable linq , expandoobject. however, since marked view @model ienumerable, no longer able use html helper because methods should resolved extension methods, not allowed , should throw runtime exception.

@html.display("property") 

the problem have properties needing rendering textbox etc. editing making compulsory me make use of html helper methods editorfor(). therefore, think might return typed models.

however, don't want mess project countless "temporary" viewmodels mixture of existing models. there way accomplish that? i'm wondering if there better solution composite class.

you can use system.reflection class properties names. example: typeof(object).getproperties


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -