This question is locked. New answers and comments are not allowed.
The sp1 version of datetimepicker has some new and unusual features that cause my apps to break.
Take the following controller code:
and view code:
Running this code crashes for any day >= 13, giving the error "String was not recognized as a valid DateTime." E.g pressing the Go Bang link gives [FormatException: 01/30/2011 00:00:00 is not a valid value for DateTime.]
This appeqars to be due to a combination of features/bugs
Sean
Take the following controller code:
public
ActionResult ShowDate(DateTime? startDate)
{
return
View(
new
DateTest { StartDate = startDate.HasValue ? startDate.Value.AddDays(1) : DateTime.Today });
}
and view code:
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"MainContent"
runat
=
"server"
>
<%
Html.Telerik().DatePickerFor(m => m.StartDate).Render();
%>
<%= Html.ActionLink("Go bang", "ShowDate", new { startDate = new DateTime(2011, 1, 30) })%>
</
asp:Content
>
Running this code crashes for any day >= 13, giving the error "String was not recognized as a valid DateTime." E.g pressing the Go Bang link gives [FormatException: 01/30/2011 00:00:00 is not a valid value for DateTime.]
This appeqars to be due to a combination of features/bugs
- DatePickerFor implicitly sets the controls Name property
- The control sets the date from the query string using the name property, even if the value has already been set
- When setting the date from the query string, the control is using the local format to decode the date rather than mm/dd
Sean