MvcScaffolding Enhancement - DisplayAttribute Support

Steve Sanderson has an excellent blog series, describing his MvcScaffolding NuGet Package.

For example, I was reading his post, describing how to override the T4 Template output generated by MvcScaffolding:

http://blog.stevensanderson.com/2011/04/06/mvcscaffolding-overriding-the-t4-templates/

I wanted to add support for any DisplayAttribute DataAnnotations on my Model classes, in those parts of the Razor views not handled by HtmlHelpers.

For example, labels for dropdown lists for RelatedEntities were based on the RelatedEntity Name property value.

With a small additional amount of logic, any associated DisplayAttribute Name can be obtained and used as an override.

The attached ZIP file contains the results of my experiments.

To use in an existing MVC3 application, simply unzip the contents of the attachment and include the CodeTemplates folder in the MVC3 Project, as a child of the root folder. Using this well-known location, MvcScaffolding will use these replacement templates instead of the defaults.

Attachment: CodeTemplates.zip
Published Saturday, May 21, 2011 1:07 PM by mj_naughton

Comments

# re: MvcScaffolding Enhancement - DisplayAttribute Support

Monday, December 24, 2012 2:38 PM by Castellano

I’m new to your blog and i actually appreciate that the nice posts

and great layout.`’`-`

# re: MvcScaffolding Enhancement - DisplayAttribute Support

Thursday, December 27, 2012 6:44 PM by Hong

that the surround sound systems for instance dolby can

actually make the home theater sounds super great“

# re: MvcScaffolding Enhancement - DisplayAttribute Support

Friday, January 11, 2013 6:01 AM by Hiatt

you use a fantastic blog here! do you would for instance to have that the invite posts in my little blog?

# re: MvcScaffolding Enhancement - DisplayAttribute Support

Saturday, January 19, 2013 3:02 AM by Bays

It seems you have been getting quite a lof of

unwanted comments. Maybe you have to look into

a solution for the. ..

Leave a Comment

(required) 
(required) 
(optional)
(required)