When utilizing my AJAX method, it returns a view model that is serialized as a data structure using
JavaScriptSerializer().Serialize()
. Among this data are several nullable DateTime?
properties.
I recently discovered that these dates appear in JavaScript as strings in the format "/Date(1480551007625)/"
. With some investigation, I found out how to convert this into a JavaScript date.
The dilemma arises when attempting to post back the data to my AJAX methods, resulting in the error message:
/Date(1480551007625)/ is not a valid value for DateTime.
This error persists even when I have made no changes to that value within the view model! Essentially, I am simply posting back the same unaltered view-model object.
How can I convert the DateTime properties within my view mode on the client side so that they may be successfully posted back to the server and converted back to DateTime
properties?