The default DisplayFor helper just throws some escaped text on the page. Is there a way to wrap the default in a <span> or <div> without writing custom DisplayFor templates for each property you want to display? Instead of it spewing out
Foo
I want it to spit out
<span>Foo</span>
I’ve seen a lot of articles for making the custom stuff; I use those quite often. But most of my display stuff I just want to handle with simple CSS where the content is wrapped in a tag, and I can’t find a reference on how to do this, or even if it’s possible.
Sure use the ‘object’ template and override as follows from ViewData.ModelMetadata.Properties
Object template – Html.Display using ViewBag
By having your display template named object.cshtml you will apply to all types with numerable properties
There’s a link to brad wilsons entry that contains the primary details
http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html