这是我的相关位
视图模型:
[Display(Name = "One Per Line")]
public bool OnePerLine { get; set; }
[Display(Name = "Comma Separated")]
public bool CommaSeparated { get; set; }
[Display(Name="Upper Case")]
public bool UpperCase { get; set; }
看法:
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-horizontal" }))
{
.
.
<div class="control-group">
@Html.LabelFor(m => m.OnePerLine, "One Per Line?", new Dictionary<string, object> { { "class", "control-label" } })
<div class="controls">
@Html.CheckBoxFor(m => m.OnePerLine)
</div>
</div>
<div class="control-group">
@Html.LabelFor(m => m.CommaSeparated, "Comma separate them?", new Dictionary<string, object> { { "class", "control-label" } })
<div class="controls">
@Html.CheckBoxFor(m => m.CommaSeparated)
</div>
</div>
<div class="control-group">
@Html.LabelFor(m => m.UpperCase, "Uppercase?", new Dictionary<string, object> { { "class", "control-label" } })
<div class="controls">
@Html.CheckBoxFor(m => m.UpperCase)
</div>
</div>
.
.
}
这是我在帖子中看到的提琴手:
OnePerLine=true&OnePerLine=false&CommaSeparated=true&CommaSeparated=false&UpperCase=true&UpperCase=false
当这到达我的控制器时,视图模型具有来自视图的正确值,我只是在帖子正文中发现加倍奇数。