How to create a name for checkbox created with mvc helper

1

How do 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 checkbox name on the left or right. I did it and it did not work:

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

I also did this and nothing

<td>@Html.CheckBox("Acesso Remoto", "Acesso Remoto")</td>
    
asked by anonymous 15.05.2014 / 18:28

2 answers

2

Response:

And in that case it only creates <input type="checkbox" name="" id=""> , so put it in the front or the way you have it!

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>
    
15.05.2014 / 18:32
1

I think this is what you want:

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