I have been working very hard on several very long views which are attached to my models through "ViewModel" intermediaries. My model is in a separate project.
All works fine but some of the fields in the view I want to hide. I have used for the most part, something like this:
<td id="Left">@Html.LabelFor(x=>x.Id)</td>
<td id="Right">@Html.TextBoxFor(model => model.Id)</td>
for all the fields so far (there are several hundred in each view.
It doesnt make sense for me to have to go into these and change many of them to HiddenFor as I have to do it in many places.
I want to know if there is an option to put it over the property of the view model like:
[Display(Name = "ID:")]
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
in order to hide both the label and the input textbox at once so only the fields I have marked show up. I am thinking that I shoudl be able to just set an attribute to do this so where am I going wrong.
Thanks in advance for any help.