Completed
Last Updated: 28 Apr 2020 17:34 by ADMIN
Release 2.11.0
Sylvain
Created on: 26 Feb 2020 15:42
Category: DatePicker
Type: Bug Report
0
DisabledDates being null throws Unhandled exception rendering component: Value cannot be null. (Parameter 'source')

When you use the DisabledDates parameter of the picker and it is null, the component throws an error that it cannot Select from the IEnumerable:

 

<TelerikDatePicker @bind-Value="@theValue" DisabledDates="@DisabledDates" />

@code{
    DateTime theValue { get; set; }
    List<DateTime> DisabledDates { get; set; }
}

 

2 comments
ADMIN
Marin Bratanov
Posted on: 09 Mar 2020 14:24

Hello,

A status update - we have reviewed this, and an exception is the expected behavior in this case. Reference types (such as lists, dates, etc.) throw a NullReferenceException when they are null but are used. We decided to keep this behavior consistent with the framework, so exceptions will continue being thrown - if you use a parameter, you should initialize the variable that it consumes.

The improvement we will make in this regard is to throw more meaningful exceptions - the default Blazor stack trace and exception messages are not very helpful and we will add the parameter name that threw the exception so that you can investigate your application logic better.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
ADMIN
Marin Bratanov
Posted on: 26 Feb 2020 15:48

A workaround is to initialize the DisabledDates collection:

<TelerikDatePicker @bind-Value="@theValue" DisabledDates="@DisabledDates" />

@code{
    DateTime theValue { get; set; }
    List<DateTime> DisabledDates { get; set; } = new List<DateTime>();
}

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor