I am trying to set the value of a hidden property using the ViewBag in MVC3. Here is what I have come up with:
@Html.HiddenFor(model => model.PROCESS_ID, new { @value = ViewBag.processID })
In the controller I set the ViewBag.processID to a long. In the View, I simply want to assign the value of that to the Process_ID of the strongly typed model. However, through the ViewBag property gets set correctly, it does not pass into the value of the hidden attribute.
Generated HTML:
<input data-val="true" data-val-number="The field PROCESS_ID must be a number." id="PROCESS_ID" name="PROCESS_ID" type="hidden" value="" />
Am I missing something? This seems simple enough. How can I accomplish this?
Why not just do this