The value '/Date(-62135578800000)/' is not valid for

5 posts, 0 answers
  1. Alexandre
    Alexandre avatar
    20 posts
    Member since:
    Apr 2014

    Posted 04 Apr 2014 Link to this post

    Hi everyone,

    I'm using a Grid to ajax edit a simple model in the inline mode and on the Controller the ModelState.IsValid is always false.
    The error message is "The value '/Date(-62135578800000)/' is not valid for Expiration."

    I have attach the relevant code of my test application and would appreciate any help.

    Alexandre Lefebvre
  2. Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 08 Apr 2014 Link to this post

    Hi Alex,

    The reason for current behavior is that the Grid build-in schema doesn't support complex models and the nested "Date" fields are not parsed. In current case I would suggest to flatter your model by creating new ViewModel and contain only the "id" of the "OtherClass" inside it. 

    Another option is to use for example the "RequestEnd" event of the DataSource to manually parse the nested date:
        .Events(e => e.RequestEnd("onRequestEnd"))

    function onRequestEnd(e) {
        for (var i = 0; i < e.response.Data.length; i++) {
            if(e.response.Data[i].Other && e.response.Data[i].Other.Expiration) {
                e.response.Data[i].Other.Expiration = kendo.parseDate(e.response.Data[i].Other.Expiration);

    Kind Regards,
    Vladimir Iliev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Alexandre
    Alexandre avatar
    20 posts
    Member since:
    Apr 2014

    Posted 08 Apr 2014 in reply to Vladimir Iliev Link to this post

    Hi Vladimir,

    Unfortunately flatten is not an option in my case. I'll will give a try to the second options, in the mean time I was able to work around the problem with a custom model binder for the datetime type.

    protected void Application_Start()
                ModelBinders.Binders.Add(typeof(DateTime), new CustomDateBinder());

                AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

    public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
                var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

                if (value.AttemptedValue.StartsWith("/Date("))
                        DateTime date = new DateTime(1970, 01, 01, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime();
                        string attemptedValue = value.AttemptedValue.Replace("/Date(", "").Replace(")/", "");
                        double milliSecondsOffset = Convert.ToDouble(attemptedValue);
                        DateTime result = date.AddMilliseconds(milliSecondsOffset);                    
                        result = result.ToUniversalTime();
                        return result;
                return base.BindModel(controllerContext, bindingContext);
  4. Anthony
    Anthony avatar
    5 posts
    Member since:
    Mar 2015

    Posted 21 Dec 2015 in reply to Vladimir Iliev Link to this post

    This was immensely helpful. What would be even more helpful would be a note of some kind in the MVC grid documentation.
  5. Marcel Härry
    Marcel Härry avatar
    33 posts
    Member since:
    Jul 2009

    Posted 01 Nov 2016 Link to this post

    Could not find my failing datetime value, but this helped. Thank you!
Back to Top