How to create a checkbox name created with mvc helper

Asked

Viewed 290 times

1

How I use the mvc helper to create a chekbox and with its name attached to the checkbox. And if there’s any way I can put the name of the checkbox on the left or right. I did so and it didn’t work:

<td>@Html.CheckBox("Acesso Remoto")</td>

I also did so and nothing

<td>@Html.CheckBox("Acesso Remoto", "Acesso Remoto")</td>
  • because then it just ta creating the <input type="checkbox"... and do not put separate name, put Accessoremoto

2 answers

2


Answer:

And in that case he only creates the <input type="checkbox" name="" id="">, then put forward or in the manner established by you!

Example

<td>@Html.CheckBox("AcessoRemoto", true ou false) Acesso Remoto</td>

<td>Acesso Remoto @Html.CheckBox("AcessoRemoto", true ou false)</td>

<td>@Html.DisplayName("Acesso Remoto:") @Html.CheckBox("AcessoRemoto", true ou false)</td>
  • Okay, that’s about it. I noticed that the label is not aligned with the check. The name of the check is slightly below the check.

1

I think this is what you want:

<td>@Html.CheckBoxFor(model => item.campoBD, new { }) Acesso Remoto</td>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.