I have two Dictionary<string, byte>
properties in my model that should validate properly with from 0 to 5 items. For example the property skill (string dropDownListLabel, byte years)
.
Because I need to support non-javascript clients, I render all 5 input pairs to the browser, only binding existing dictionary items, and life is great. This gives 5 empty input pairs for a new plain HTML form, each with unique input names, which I also want.
Here's the serialization (input names) I use:
skill[0].Key = "", skill[0].Value = ""
... three more pairs ...
skill[4].Key = "", skill[4].Value = ""
But on POST, for Key/Value pairs with neither Key nor Value specified, DefaultModelBinder validation errors result on Value.
Is there a type and serialization I can use that will validate in DefaultModelBinder when both or neither Key and Value are POSTed, so MVC does as much work for me as possible, only adding pairs into a collection when they have content?
Thanks, Shannon