I have this line in my View:
@Html.EditorForModel()
And this is my ViewModel:
public class CommentForm
{
public int Id { get; set; }
[DisplayName("Kommentar"), DataType(DataType.MultilineText)]
public string Comment { get; set; }
}
The problem is that Id
renders as a textfield in the form. Actually, I only want to use Id
in the form action. Is there an attribute that tells the editor not to render the property Id
?
Setting ShowForDisplay and ShowForEdit to false is already done by the standard
[System.ComponentModel.DataAnnotations.ScaffoldColumn(false)]
attribute. Your custom attribute therefore seems like overkill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With