Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LabelFor + EditorFor on the same line?

I have this code:

<div class="editor-label">
    @Html.LabelFor(model => model.Ticket)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Ticket)
    @Html.ValidationMessageFor(model => model.Ticket)
</div>

How do I get the label and checkbox(in this case its a checkbox) on the same line? I have tried removing the divs and they still come out on different lines.

Thank you.

like image 391
Kyle Avatar asked Dec 21 '22 21:12

Kyle


1 Answers

Removing the didn't work for my app, but adding new { @style = "display:inline-block" } as the second argument on the LabelFor() did.

I prefer the checkbox before the label so it would be:

<div>
    @Html.EditorFor(model => model.GetAll)
    @Html.LabelFor(model => model.GetAll, new { @style = "display:inline-block" })
</div>
like image 89
Ken Mc Avatar answered Jan 06 '23 10:01

Ken Mc