问题
I did some searching for determining which radio button is selected and if checkboxes are checked or not just using the FormCollection that is being passed to my Action method.
For reasons I won't go into here, I can't use Html helpers so the auto adding of hidden fields is out for me. I did find someone that suggested using GetValue() on the collection object to determine which radio button is selected, but I can't seem to make that work as it is looking for a ValueProvider and I"m not sure where to put that in.
Basically I just want to be able to determine which radio button is clicked and if a checkbox is checked or not with a form collection....why is that so hard?
Can anyone point me in the right directon please?
回答1:
Been a while since I have looked at this but could it have something to do with check boxes only being submitted if they are checked.
As in if it is submitted its checked.
Iterate through the items in the form if the name of your check box appears its been submitted.
回答2:
I ended up serializing my post array and the radio buttons and checkboxes just worked.
来源:https://stackoverflow.com/questions/7397238/checkboxes-and-radio-buttons-in-mvc-formcollection