Click here to Skip to main content
15,608,738 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I tried the code below, but it shows in view label and textbox vertically.

What I have tried:

<div class="form-group">
       @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
       <div class="col-md-10">
           @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
           @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
Updated 9-Feb-22 8:58am

1 solution

Assuming this is Bootstrap, you need to add the row class to the form-group element:
<div class="form-group row">
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900