how to place date and time on [Datatype(Datatype.Datime)]

Asked

Viewed 19 times

0

Gentlemen, I’m trying to make it easy to enter date and time data for the user,.

my class was like this Link >from my class "Query" https://dotnetfiddle.net/ZHPHKK

(as the link and image does not have a method to change its Date property
Only

     [Display(Name = "Data e Hora")]
[DataType(DataType.DateTime)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0: MM/dd/yyyy HH:mm}")]

I tried to put the <input type="datetime" but without success

Example below is (on the right side is the way it is I want to leave ingual to the left side) inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Pagina Create

@model Consulta

@{
    ViewData["Title"] = "Nova Consulta";
}

<h2>@ViewData["Title"]</h2>
<hr />
<div class="row">
    <div class="col-md-4">
        <form asp-action="Create">
        <div asp-validation-summary="All" class="text-danger"></div>
        <div class="form-group">
            <label asp-for="Data" class="control-label"></label>
            <input asp-for="Data" class="form-control" />
            <span asp-validation-for="Data" class="text-danger"></span>

        </div>
            <div class="form-group">
                <label asp-for="StatusPagamento" class="control-label"></label>
                <select asp-for="StatusPagamento" class="form-control"></select>
                <span asp-validation-for="StatusPagamento" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Comentario" class="control-label"></label>
                <input asp-for="Comentario" class="form-control" />
                <span asp-validation-for="Comentario" class="text-danger"></span>
            </div>
            <div class="form-group">
                <input type="submit" value="Enviar" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-action="Index">Voltar</a>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

I’m sorry the way I formulated my question I’m "new here" I’m learning to use the tool. Sorry about the headache !

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.