问题描述:

@Html.HiddenFor(model => model.JobIndicator)

The value for JobIndicator doesn't get refreshed after submitting the page.

I can see the value getting updated when I have it in the display field.

网友答案:

Put this in your controller :

ModelState.Remove("JobIndicator");

Then your hidden field will be updated.

网友答案:

The problem is Html helpers get data from ModelState and not from model you pass when you call post action.To solve this, you can call ModelState.Clear() in the post action before you return your view, this way the info in the ModelState is going to be cleared and repopulated once your view is regenerated.

You can find more info about this issue (and other solutions) in this blog

网友答案:

Just make sure to put this line inside the form tag

@Html.HiddenFor(model => model.JobIndicator)
相关阅读:
Top