I\'m using MVC 2 for a project and I\'m having a problem with a view. In the controller I have the code:
return View(calendarDay);
If I deb
Seems like the problem is that the view is using the id from the controller and not the one from the model. I just changed the parameter name and works fine now.
I suspect that you are trying to modify the POSTed value (which is 1) in your controller action to 2. This is not possible because that's how all HTML helpers work and it is by design: they will first look at the POSTed value when binding and after that in the model. So the HiddenFor
helper ignores the Id of your model and uses the one that's posted.
As a workaround you could:
<input type="hidden" name="Id" value="<%: Model.Id %>" />
As suggested by @jfar in the comments section another workaround is to clear the model state in the post action before returning the view:
MoselState.Clear();