There is a page:

@model WebApplication1.Models.EditVM @{ ViewBag.Title = "Edit"; } <body> <h3>Редактирование графика работы по элементу содержания</h3> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-md-2">Количество выделенных часов:</label> <input type="date" class="form-control"> </div> </div> } </body> 

enter image description here

1. And the first question immediately: I could not manage to align the label and input . label as you can see a little omitted. How to align them?

But this is not the main issue. I need to use a helper instead of input to bind to the model field and this is how I do it:

  <div class="form-group"> <label class="control-label col-md-2">Количество выделенных часов:</label> @Html.EditorFor(x => x.PlanOO.HoursDateStart, new { @class = "form-control" }) </div> 

enter image description here

2. Now the field has become "not beautiful, turned into a kind of 2d format)."

3. and it is no longer a DateTime format

What can be done on these 3 points?

    1 answer 1

    Add to property models:

     [DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] 
    • thank. Is there a suggestion for the first question? - Adam
    • one
      Set Labelu at least col-md-5, and input wrap in a div c class = "col-md-6" for example. - cpp_user