We just added a new dropdown list to one of our forms, which has a javascript function to change the background colour of a textarea. And the UpdateModel() on our controller class promptly fell over ...
It turns out that UpdateModel() requires your class to have a property it can map for every form control with a Name(presuming you are using the lazy 'Request.Form.AllKeys')... or it throws an exception ... not the most helpful or obviously expected behaviour. Instead, use TryUpdateModel(), or use our quick fix to remove the Name from our dropdown as it wasn't needed.
For binding that uses reflection, I would far rather the default behaviour was just to ignore the property ... this would allow views to be changed more easily without having to change the controller.
Posted
09-04-2008 10:31 AM
by
Jak Charlton