Why is a boolen value duplicated in the form serialize when checked = "checked"?

47 Views Asked by At

I have a boolean value bound to CheckBoxFor or EditorFor (either one).

Here is the model declaration:

public bool IsActive { get; set; }

Here is the html (as you can see I've tried multiple variations):

<div>
@*@Html.CheckBoxFor(model => model.IsActive, new { htmlAttributes = new { @class = "form-control" } )*@

@*@Html.CheckBoxFor(model => model.IsActive)*@

@*@Html.EditorFor(model => model.IsActive, new { htmlAttributes = new { @class = "form-control" } })*@

@Html.EditorFor(model => model.IsActive)

</div>

I seem to have a side-effect that whenever I check the box, the IsActive value is duplicated in the form. I alert the serialize before the post and this is what it looks like when the box is checked:

...&IsActive=true&IsActive=false...

When the box is not checked it's only ...&IsActive=false...

What could cause this behavior? TIA

0

There are 0 best solutions below