HTML.HiddenFor value set

arnoldrob picture arnoldrob · Sep 3, 2012 · Viewed 124.5k times · Source
@Html.HiddenFor(model => model.title, new { id= "natureOfVisitField", @value = '@Model.title'})

it doesen't work! how to set the value?

Answer

user1187093 picture user1187093 · May 2, 2013

For setting value in hidden field do in the following way:

@Html.HiddenFor(model => model.title, 
                new { id= "natureOfVisitField", Value = @Model.title})

It will work