I have an asp.net page with a an html5 TextBox control set as the "date" type. The control on my page looks like this:
<asp:TextBox ID="TextBoxMyDate" runat="server" type="date"/>
It works great in the page and I can click on it and set the date. I can also read the date through TextBoxMyDate.Text. However, I cannot figure out how to programaticaly set the date. I have tried various formats of:
TextBoxMyDate.Text = DateTime.UtcNow.ToString("MM/dd/yyyy")
TextBoxMyDate.Text = DateTime.UtcNow.ToString("MM/dd/yyyy")
My guess is that its much more complicated than simply setting the text value but I don't know where to go from here. Any suggestions?
This is actually the correct way to set the date but the format was wrong!
TextBoxMyDate.Text = DateTime.UtcNow.ToString("yyyy-MM-dd");
I was confusing how the browser displays the date and the html5 standards for this control!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With