Html.HiddenFor value property not getting set

前端 未结 6 1758
借酒劲吻你
借酒劲吻你 2020-12-09 15:26

I could have used

@Html.HiddenFor(x=> ViewData[\"crn\"])

but, I get,

6条回答
  •  鱼传尺愫
    2020-12-09 15:57

    I believe there is a simpler solution. You must use Html.Hidden instead of Html.HiddenFor. Look:

    @Html.Hidden("CRN", ViewData["crn"]);
    

    This will create an INPUT tag of type="hidden", with id="CRN" and name="CRN", and the correct value inside the value attribute.

    Hope it helps!

提交回复
热议问题