c# - Template for ViewBag -
i want create template format viewbags.
now, had case of property of of class, modify
[uihint("mytemplate")] public virtual float foo { get; set; }
every selction of property consider "mytemplate" , formate output correctly.
how able transfer 'structure' viewbag, defined in controller?
actuall, can't. contents of viewbag dynamically resolved @ runtime. opposed model properties. can use templates properties of model.
the other option add model. reason behind that, model (or view model precise) ought have view needs display data. viewbag intended add flexibility data doesn't need in model contents of dropdownlist. therefore, if need display content viewbag properties in page, should consider promoting property model.
alternatively, use partial views. @html.partial("_mytemplate",viewbag.data)
Comments
Post a Comment