Разница при использовании htmlAttributes - PullRequest
0 голосов
/ 04 октября 2018

В чем разница между:

@Html.LabelFor(model => model.Soluongton, htmlAttributes: new { @class = "control-label col-md-2" })

и

@Html.LabelFor(model => model.Soluongton, new { htmlAttributes = new { @class = "control-label col-md-2" } })  

и что такое htmlAttributes?

1 Ответ

0 голосов
/ 04 октября 2018
@Html.LabelFor(model => model.Soluongton, htmlAttributes: new { @class = "control-label col-md-2" })

отобразит код HTML:

<label class="control-label col-md-2" for="Soluongton">Soluongton</label>
@Html.LabelFor(model => model.Soluongton, new { htmlAttributes = new { @class = "control-label col-md-2" } })  

отобразит код HTML:

<label for="Soluongton" htmlAttributes="{ class = control-label col-md-2 }">Soluongton</label>

Как вы можете видеть, второй @Html.LabelFor отобразит неверный вывод HTML.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...