This question is locked. New answers and comments are not allowed.
We have a problem when we use the DatePicker inside an EditorTemplate. The problem is that the name that it assumes for all instances after the first instance is identical to the first instance's name, which causes the javascript to break.
Our ViewModel:
Our View:
Our EditorTemplate:
I've put in a temporary work-around where I force the Name in the EditorTemplate to something unique (Name="Foo" + Model.GetHashCode() will do it) but this is obviously a terrible idea as it breaks validators and such. However, it's sufficient enough to prove that the DatePicker has issues naming itself.
Any solid workarounds or fixes for this?
Our ViewModel:
public
class
Foo
{
DateTime? StartDate {
get
;
set
; }
DateTime? EndDate {
get
;
set
; }
}
Our View:
<%= Html.EditorFor(m => m.StartDate, "General/DateTime") %>
<%= Html.EditorFor(m => m.EndDate, "General/DateTime") %>
Our EditorTemplate:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<
System.DateTime
?>" %>
<%= Html.Telerik().DatePicker()
.Value((Model.HasValue ? Model.Value : DateTime.Today))
.ShowButton(true) %>
I've put in a temporary work-around where I force the Name in the EditorTemplate to something unique (Name="Foo" + Model.GetHashCode() will do it) but this is obviously a terrible idea as it breaks validators and such. However, it's sufficient enough to prove that the DatePicker has issues naming itself.
Any solid workarounds or fixes for this?