I am learning Blazor and have no experience with component-based programming. I have two components: a DateRangePicker and a RadzenCheckBox. The requirement is that when the checkbox is clicked, two calendars should be shown, and when it’s unchecked, only one calendar should be visible. I wrote the following code:
@code{
DateRangePicker calendar;
public void txtBoxChange(bool args)
{
if (args == true) //shows one calendar when checked
calendar.ShowOnlyOneCalendar = true;
else //shows two calendars when unchecked
calendar.ShowOnlyOneCalendar = false;
}
}
However, I get a warning that “Component parameter ‘ShowOnlyOneCalendar’ should not be set outside of its component”. What is the best way to achieve this requirement without getting the warning?
You should create a parameter ShowOnlyOneCalendar in your DateRangePicker component and pass the value from the RadzenCheckBox component to this parameter. Here’s an example of how to do it: