Reputation: 37905
I have a Form with two fields, Key and Value.
This is displayed in a form with:
@Html.LabelFor(m=> m.Key)
@Html.DisplayFor(m => m.Key)
@Html.LabelFor(m=> m.Value)
@Html.TextBoxFor(m=> m.Value)
Note that the user cannot edit m.Key, only m.Value.
This works. However, what posts with the Form is only m.Value which I would expect. However, I really do need m.Key to be returned as well.
How can I do this?
Greg
Upvotes: 0
Views: 71
Reputation: 171401
You can do:
@Html.HiddenFor(m=> m.Key)
This will create a hidden input with your key that will get POSTed back when your form is submitted.
Upvotes: 2