A
A
Alosxkj2021-06-11 21:20:02
ASP.NET
Alosxkj, 2021-06-11 21:20:02

How to pass DateTime from View to Controller?

Actually a subject. Here is the View

@model HotelSite.ViewModels.OrderViewModel
<h2>Заказать номер</h2>
<form method="post" asp-controller="Order" asp-action="Index">
    <div asp-validation-summary="ModelOnly"></div>
    <div>
        <label asp-for="StartDate"></label><br />
        <input type="date" asp-for="StartDate" />
        <span asp-validation-for="StartDate"></span>
    </div>
    <div>
        <label asp-for="EndВate"></label><br />
        <input type="date" asp-for="EndВate" />
        <span asp-validation-for="EndВate"></span>
    </div>
 
    <div>
        <input type="submit" value="Забронировать" />
    </div>
</form>


The controller itself is still empty, I just want to get data into it, but it doesn’t come out
public IActionResult Index(OrderViewModel model)
   {
               
      return View();
   }

Empty values ​​are coming. How to correctly pass DataTime?
PgPAQ.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Bereznikov, 2021-06-12
@gdt

Could this be of any help? https://www.youtube.com/watch?v=dsk4YyDEn4w

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question