Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 4 HiddenFor field not appearing in rendered markup

Am using MVC 4 and want to maintain some values on postback, so they're going into hidden fields. In essence:

@using (Html.BeginForm())
{
    Html.HiddenFor(model => model.EventId);
    Html.HiddenFor(model => model.paymentMethodId);
}

But the hidden fields are not appearing in the rendered markup and are therefore - obviously - missing on postback.

like image 454
Mark Avatar asked Nov 21 '25 15:11

Mark


1 Answers

You need to add a @, @Html.HiddenFor(). Otherwise you're just executing the helper method, but not actually doing anything with the output.

like image 50
dom Avatar answered Nov 24 '25 08:11

dom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!