lundi 16 avril 2018

ASP.NET Core placement of hidden field of checkbox

I have a form and checkbox inside that form. My model contains bool property, and I have to show that as a checkbox like this:

<form asp-controller="Home" asp-action="Index" method="post">
    <input asp-for="IsDefault" />
    <button type="submit" class="btn btn-default">Submit</button>
</form>

When I look at source html code, I see that hidden field generated for this checkbox is right before closing form tag.

If I many fields on form, some of them checkboxes, all hidden fields of checkboxes will be placed before closing form tag.

Same logic when I use @Html.CheckBox or @Html.CheckBoxFor .

Before in ASP.NET MVC projects hidden field will be placed next to corresponding checkbox. Why that logic changed?




Aucun commentaire:

Enregistrer un commentaire