Hai Tran
Hai Tran

Reputation: 107

Pass Kendo DatePicker value to Asp.net MVC Controller

this is first time i work with KendoUI and found there was no tutorial for my case.

I have a model:

public class SelectedDate{
     public DateTime BirthDay {get;set;}
}

First, i have a GET action as:

public ActionResult ShowDate(){
   return View(new SelectedDate());
}

on ShowDate.cshtml, i used a kendoUI named DatePicker as follow

@model SelectedDate

@(Html.Kendo().DatePickerFor(c => c.BirthDay ).Format("dd/MM/yyyy").Value(DateTime.Now))

and some button inside form

When i submit this form, model and data parsed into action successfully. But the BirthDay value always was {1/1/0001 12:00:00}

here my Action

[POST]
public ActionResult ShowDate(SelectedDate model){
       //model.BirthDay = {1/1/0001 12:00:00}
}

I tried too many way, but still incorrect. How can i find a solution ?

Upvotes: 0

Views: 2222

Answers (1)

Chien Dang
Chien Dang

Reputation: 115

I met the same problem yesterday, then I changed date format from "dd/MM/yyyy" to "yyyy-MM-dd" and it run ok. But exactly I sent a string (_playlistDate variable below)to Controller, it looks like:

_playlistDate = kendo.toString(kendo.parseDate(this.value()), 'yyyy-MM-dd');

Hope that helps!

Upvotes: 1

Related Questions