Send date from the view to an input of type: date

0

I need that in this field I have the date I sent from the view of C #

I have the following line of code in the view of c #, but it does not work for me:

<td>
    <label for="FechaVencimiento">Fecha Vencimiento:</label>
</td>
<td>
    @Html.TextBoxFor(model => model.Facturas.FechaVencimiento, new { @class = "form-control  input-sm", @type = "Date", @required = 1, date = Model.Facturas.FechaVencimiento })
</td>

Which label should I use in the c # view to send the date correctly and load it in the browser?

    
asked by Jhon Castrillon 20.06.2017 в 23:45
source

2 answers

0

If FechaVencimiento is of type DateTime it should be enough to do:

@Html.EditorFor(m=> m.Facturas.FechaVencimiento, new {htmlAttributes = new {@class= "form-control input-sm"}})
    
answered by 21.06.2017 в 00:25
0

Many times the input does not recognize the data type DateTime , you have to format it.

Try the following line:

@Html.TextBoxFor(model => model.Facturas.FechaVencimiento, new { @class = "form-control  input-sm", @type = "Date", @required = 1, date = Model.Facturas.FechaVencimiento.ToString("dd/MM/yyyy") })

I'm just adding .ToString("dd/MM/yyyy") to format the date

    
answered by 21.06.2017 в 00:25