Asp.Net Mvc Hidden Field from Data Annotations Asp.Net Mvc Hidden Field from Data Annotations asp.net asp.net

Asp.Net Mvc Hidden Field from Data Annotations


This property:

[System.Web.Mvc.HiddenInput(DisplayValue = false)]public int Id { get; set; }

will be rendered as i.e.

<input id="Id" name="Id" type="hidden" value="21" />

when using Html.EditorForModel() or Html.EditorFor(m => m.Id)