Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore some fields using the helper @Html.EditorForModel()

I use helper @Html.EditorForModel() on all my views.

There is a desire that he skip two fields in my model, but only on this view, the other he must continue to display these fields as usual.

How can I skip these two fields only in this view?

like image 275
ridermansb Avatar asked Jul 28 '11 14:07

ridermansb


1 Answers

Use the [ScaffoldColumn(false)] attribute.

E.g.

public class Person {
    [ScaffoldColumn(false)]
    public int PersonID { get; set; }
    ...

Solution and example sourced from: Pro ASP.NET MVC 3 Framework, Third Edition

like image 88
Ryan Kirkman Avatar answered Nov 06 '22 05:11

Ryan Kirkman