Search code examples
asp.net-mvcrazortelerikdatetimepicker

Asp.net mvc Razor view - Telerik().DateTimePicker() inside Telerik().TabStrip() gives JS error


Any help would be appreciated!

Here is the code in the main view, lets say Account/Index.cshtml

@( Html.Telerik().TabStrip()
           .Name("TabStrip")
            .Effects(fx => fx.Expand()
                            .Opacity()
                            .OpenDuration(200)
                            .CloseDuration(300))
           .HtmlAttributes(new { @Style = "width:800px;" })
           .SelectedIndex(0)
           .Items(parent => {
                parent.Add()
                    .Text("Article")
                    .LoadContentFrom("ChangePassword", "Account");
                parent.Add()
                    .Text("Users")
                    .LoadContentFrom("_Register", "Account");
                })
    )

In the "_Register" view, i have the below

 @(Html.Telerik().DatePicker()
       .Name("DatePickerAttributes.SelectedDate")
       .Value(DateTime.Today)
  )

It seems that, in IE, it throws an error and Calendar is not at all opening. But if i add the below manually, even though JS error, the calendar opens

 jQuery(document).ready(function () {
        jQuery('#DatePickerAttributes_SelectedDate').tDatePicker({ format: 'M/d/yyyy', minValue: new Date(1899, 11, 31), maxValue: new Date(2100, 00, 01), selectedValue: new Date(2011, 06, 09) });
    });

Note: If firefox, it works great without any error.

Hope that, in IE, LoadContentFrom("_Register", "Account"); not loads the view completely, but fine in FireFox.


Solution

  • Are the Required JavaScript files by the DatePicker registered? You need to do so for components loaded on demand via LoadContentFrom. The troubleshooting help article show how.