Editor type DateTime does not show the date but in the input if the value appears

1

I am developing an application in ASP.Net MVC5 that contains a pattern of workers, among the data that must be captured is the date. Now the problem is that in my Edit view if I load the value that comes from the model in the input, however in design it does not show it to me. Here I leave first the image of my editing page:

What is marked in red should bring the date of birth data. If I get into the source code of the page I see that the value is loaded in the value property of the input but it is not displayed in the control

And then the code in razor.

Any suggestions that I'm doing wrong ?. I hope someone can help me, I already tried several solutions that I saw in forums and none of them solves my problem. Greetings!

    
asked by Alfredo Manuel Can Reséndiz 14.11.2018 в 00:27
source

2 answers

1

To show the date and time in an HTML component you must use a input of type date and pass it the value formatted as follows:

año-mes-dia
  

Note: The day and month must have two digits and the year four .

For example, if you want to show on February 1, 2018, it would look like this:

<input type="date" value="2018-02-01">
    
answered by 14.11.2018 / 00:40
source
1

You could see using something like this

@Html.EditorFor(model => model.FechaNacimiento, new { @type = "date" })

but the format is applied by means of the attribute in the model

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime FechaNacimiento{ get; set; }

How to use Html.TextBoxFor with input type = date ?

    
answered by 14.11.2018 в 00:59