I've defined two <SfDateTimePicker> components and defined an event that will update the EndTime upon OnCliose.
<div class="form-row">
<div class="form-group col-md-6">
<SfDateTimePicker @[email protected] Placeholder="Start Time" FloatLabelType="FloatLabelType.Auto">
<DateTimePickerEvents TValue="DateTime?" OnClose=@StartOnClose />
</SfDateTimePicker>
</div>
<div class="form-group col-md-6">
<SfDateTimePicker @bind-Value="@Meeting.EndTime" Placeholder="End Time" FloatLabelType="FloatLabelType.Auto" />
</div>
</div>
When the <DateTimePickerEvents TValue="DateTime?" OnClose=@StartOnClose /> is present the code abort with:
[2021-01-05T13:53:16.401Z] Information: Normalizing '_blazor' to 'https://localhost:44343/_blazor'.
blazor.server.js:1 [2021-01-05T13:53:16.432Z] Information: WebSocket connected to wss://localhost:44343/_blazor?id=0xZLdDpODosUb7-PFMYRWQ.
blazor.server.js:19 [2021-01-05T13:53:27.572Z] Error: System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Blazor.Calendars.DateTimePickerEvents`1.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
e.log @ blazor.server.js:19
C @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:1
e.invokeClientMethod @ blazor.server.js:1
e.processIncomingData @ blazor.server.js:1
connection.onreceive @ blazor.server.js:1
i.onmessage @ blazor.server.js:1
blazor.server.js:1 [2021-01-05T13:53:27.573Z] Information: Connection disconnected.
When the Event is commented out the code runs.
|
<div class="form-row">
<div class="form-group col-md-6">
<SfDateTimePicker TValue="DateTime?" @bind-Value=@StartTime Placeholder="Start Time" FloatLabelType="FloatLabelType.Auto">
<DateTimePickerEvents TValue="DateTime?" OnClose=@StartOnClose />
</SfDateTimePicker>
</div>
<div class="form-group col-md-6">
<SfDateTimePicker TValue="DateTime?" @bind-Value="@EndTime" Placeholder="End Time" FloatLabelType="FloatLabelType.Auto" />
</div>
</div>
@code{
public DateTime? StartTime { get; set; } = DateTime.Now;
public DateTime? EndTime { get; set; }
public void StartOnClose(PopupObjectArgs args)
{
// Here you can customize your code
EndTime = StartTime.Value.AddHours(1);
}
} |
Thank you for your reply.
The TValue on the SfDateTimePicker
What I discovered was that when I did add a TValue to the SfDateTimePicker
Thanks for the help.
Mike