My code is like this
<div class="form-group" style="padding-top: 30px;">
@Html.CheckBoxFor(model => model.IsVatPaidByInsurer)
</div>
Inside Model Class
public bool IsVatPaidByInsurer { get; set; }
Inside Controller
public ActionResult Create([Bind(Include = "PayerID,Name,CreatedDate,PayerTypeSelected,ReferingInstitute,ApplicationUserId" +
"IsVatPaidByInsurer,PatientContribution")] Payer payer)
I expect this line of code to generate a checkbox on front end, But how it renders is like this (value not true, it's I just checked the checkbox)
<div class="form-group" style="padding-top: 30px;">
<input data-val="true" data-val-required="The IsVatPaidByInsurer field is required." id="IsVatPaidByInsurer" name="IsVatPaidByInsurer" type="checkbox" value="true">
<input name="IsVatPaidByInsurer" type="hidden" value="false">
</div>
As you can see there is two inputs with same name generated (IsVatPaidByInsurer). And second one's value always false. So when I make my form post I can't get the real value of checkbox.It will interpret always as false there. Can anyone Tel me what This is whole about? and a way to overcome this?