asp.net-mvcasp.net-mvc-3html-helperhtml.hiddenfor

HTML.HiddenFor value set


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

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


Solution

  • You shouldn't need to set the value in the attributes parameter. MVC should automatically bind it for you.

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