2
I own the following Textboxfor
@Html.TextBoxFor(model => model.data, "{0:dd/MM/yyyy}", new { @class = "form-control", @alt = "date", @placeholder = DateTime.Now.Date.ToString("dd/MM/yyyy"), @maxlength = "10", @data_val="false"})
As you can see, there is a placeholder that defines what will appear on it when the screen opens. My question is, How do I put today’s date in the actual content of Textboxfor? For, when I open the screen without filling the textbox it accuses that this empty, ie being displayed that today’s date is set in the field, but only visually.
Thank you.
Ever tried to add
@value = DateTime.Now.Date.ToString("dd/MM/yyyy")
?– Pablo Carvalho
Good afternoon. I tried to perform your tip, but it still didn’t work. When I open the screen and do the 'Submit' with the form button below the date field is displayed the error message (previously made by me) as if the field is empty. Would you have any suggestions to be made at Controler?
– Geisson Lucas de Oliveira
I realized that the problem was not to use value = "". This is correct, but for a small detail, one should use Value = " (capital 'v'). Thanks for the tip. Worked well.
– Geisson Lucas de Oliveira