@Html.HiddenFor(model => model.title, new { id= "natureOfVisitField", @value = '@Model.title'})
it doesen't work! how to set the value?
@Html.HiddenFor(model => model.title, new { id= "natureOfVisitField", @value = '@Model.title'})
it doesen't work! how to set the value?
Necroing this question because I recently ran into the problem myself, when trying to add a related property to an existing entity. I just ended up making a nice extension method:
Use like so:
Note that this has a similar signature to the built-in HiddenFor, but uses generic typing, so if Value is of type System.Object, you'll actually be invoking the one built into the framework. Not sure why you'd be editing a property of type System.Object in your views though...