views:

27

answers:

2

If I understand the [ScaffoldColumn(false)] attribute correctly, I should be able to decorate a variable with this and then, when I create a strongly-typed Edit view, that field will show up as hidden text and NOT a Label/Textbox pair.

I am using entity framework and then adding a partial class with an inner metadata class like so:

[MetadataType(typeof(AlumniInterest_Metadata))]
public partial class AlumniInterest
{
    private class AlumniInterest_Metadata
    {

        [ScaffoldColumn(false)]
        [DisplayName("Person Id")]
        [StringLength(8)]
        public object person_id { get; set; }

        [DisplayName("Interest")]
        [StringLength(35)]
        public string interest_desc { get; set; }
    }
}

This partial is in the same namespace as the EF generated class and the DisplayName attribute IS being picked up so I think things are wired correctly. I tried changing the type from string to object (based on some google search results) but that did nothing.

Anyone else run into this problem? Have I made a newb error?

+1  A: 

The MVC tooling does not reason about ScaffoldColumnAttribute. This attribute is only used when you invoke the Html.DisplayForModel or Html.EditorForModel methods.

If you wanted the Add View dialog to honor ScaffoldColumnAttribute you could edit the T4 template file that's used to generate a View.

marcind
thanks for the answer
indyDean
+1  A: 

The [ScaffoldColumn(false)] does not seem to work as you would expected. You will need to set

 Html.HiddenFor(model => model.person_id)

in your view manually.