This is a migrated thread and some comments may be shown as answers.

DateTimeOffset Solution?

1 Answer 346 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 14 Jun 2019, 03:08 PM

I was having binding issues using the kendo-datepicker tag helper using a DateTimeOffset property from my pagemodel, and could only find threads about this being a known issue. so I created my own custom tag helper that inherits from DatePickerTagHelper, and added this code to the Process method:

 

if (For.Metadata.ModelType == typeof(DateTimeOffset))

            {
                var dto = (DateTimeOffset)For.Model;
                Value = dto.Date;
            }

 

My dates now render when the page loads, and are properly passed during the post. All of my previous attempts only allowed one or the other. Are there any issues with this approach that I might be missing?

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 19 Jun 2019, 01:58 PM
Hi Patrick,

The approach you are using is correct. Since DateTimeOffset is not supported out of the box in order to use it the recommended approach is to create a new field using only the Date part from DateTimeOffset. 


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Date/Time Pickers
Asked by
Patrick
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or