Using <DateTimePickerEvents> cause abort
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.
DateTimePickerEvent_14ea15f7.rar
SIGN IN To post a reply.
3 Replies
BC
Berly Christopher
Syncfusion Team
January 6, 2021 07:31 AM UTC
Hi Mike,
Greetings from Syncfusion support.
We checked your provided code snippet and video. We suggest you to provide the TValue property for DateTimePicker components and update the another DateTimePicker value in close event as like below highlighted code to get rid of the reported issue.
|
<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);
}
} |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Blazor_dateTime-1933332669
Please get back us if you need further assistance.
Regards,
Berly B C
MC
Mike Chafin
January 6, 2021 11:04 AM UTC
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
BC
Berly Christopher
Syncfusion Team
January 7, 2021 05:39 AM UTC
Hi Mike,
We are glad to know that your issue is resolved. Please let us know if you need further assistance on this.
Regards,
Berly B.C
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MC Mike Chafin
- Jan 5, 2021 02:15 PM UTC
- Jan 7, 2021 05:39 AM UTC