Reputation: 671
I have an input tag which I want to display a date:
<input type="text" name="myDate" value="<%: tab.StartDate %>" class="datepicker"/>
where 'tab.StartDate' is a field of type DateTime from a linq statement and datepicker is the ajax control.
....StartDate = (DateTime)c.StartDate,...
The value I saved, for the 2nd March, 2013, is '2013-03-02'. The value displayed in the above input tag is 32/20/1312. I see that it is the right date but not formatted properly i.e. the month and first two digits is the year nn/20/13nn
How do I format this to read correctly?
Upvotes: 1
Views: 86
Reputation: 3314
Can you simply call the String.Format
method from the view?
<input type="text" name="myDate" value="<%: String.Format("{0:MM/dd/yyyy}", tab.StartDate) %>" class="datepicker"/>
Upvotes: 2