This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
@Html.CheckBoxFor()
falls back to values in ViewDataDictionary
#1483
Comments
E.g. the following in a create view ViewData["Alive"] = true;
...
<td>
@Html.LabelFor(m => m.Alive)
</td>
<td>
@Html.CheckBoxFor(m => m.Alive)
or
@Html.RadioButtonFor(m => m.Alive, value: false) False
@Html.RadioButtonFor(m => m.Alive, value: true) True
</td> The checkbox should not be selected. The radio button by contrast correctly shows the expression result is neither |
This bug also affects the Workarounds include not adding entries to Fix is to change one line to ensure |
dougbu
added a commit
that referenced
this issue
Jan 16, 2015
- show `@Html.CheckBoxFor()` reading from the `ViewDataDictionary` - generated checkbox and radio buttons will be consistent once bug is fixed
dougbu
added a commit
that referenced
this issue
Jan 16, 2015
- #1483 - update tests to match nits: - cover a couple more `CheckBoxFor` test cases - capitalize "CheckBox" consistently
Remove the sample and |
dougbu
added a commit
that referenced
this issue
Jan 17, 2015
- #1483 - update tests to match nits: - cover a couple more `CheckBoxFor` test cases - capitalize "CheckBox" consistently
Fixed via 12565da |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When the expression result is
null
e.g. in a Create view,@Html.CheckBoxFor()
finds value (if any) in theViewDataDictionary
. This is incorrect and inconsistent with other HTML helpers. Expression-based helpers should not useViewDataDictionary
and the rest do not.The text was updated successfully, but these errors were encountered: