This is the text box:
<asp:TextBox ID="BirthDateEdTB" runat="server" MaxLength="50" TextMode="Date" class="form-control" DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy" required="required"></asp:TextBox>
I have an object of user
that has birthdate
from type DateTime. I took this date, and I want to show it in the textbox.
I tried looking for ideas but didn’t find anything that works.
2
Answers
Can you try this code?
CONVERT(DATETIME,dateTimePicker1.Value.ToString("yyyy-MM-dd"),102)
You can set "any" format you want for the text box.
However, WHEN you attempt to fill it out, you STILL want to use a iso date format.
so, say this date:
So, while you have a forced/custom format of dd/MM/yyyy, you STILL are to feed the control a iso date format (like yyyy-MM-dd).