kendo日期选择器未将选定值传递给控制器 [英] kendo date picker not passing selected value to the controller

查看:68
本文介绍了kendo日期选择器未将选定值传递给控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从剑道日期选择器()分配日期,但是它没有将所选日期传递给控制器​​,而是传递了一些默认值



i am assigning the date from kendo date pickerfor() but its not passing the selected date
selected date to controller but instead passing some default value

@(Html.Kendo().DatePickerFor(model => model.DOB)
         .Name("dob")
//The name of the datepicker is mandatory. It specifies the "id" attribute of the widget.
.Value(DateTime.Today) //Set the value of the datepicker
             .Start(CalendarView.Year))

推荐答案

+传递+日期时间+值+时http://forums.asp.net/t/1958162.aspx?Null+value+when + PAS唱歌+日期时间+值+从+视图+到+控制器,你可以添加数据处理程序:



.Update(update => update.Action(Edit,YourControllerName,new {entity = Model}) .Data(onUpdateRequest_Details)



然后将fumction体指定为:



As mentioned at http://forums.asp.net/t/1958162.aspx?Null+value+when+passing+DateTime+value+from+View+to+Controller, you can add data handler as:

.Update(update => update.Action("Edit", "YourControllerName", new { entity = Model }).Data("onUpdateRequest_Details"))

Then specify the fumction body as:

function onUpdateRequest_Details(e) {
    e.LastStatementDate =


#< YourDateFieldName>)。val(); // 设置字符串值
}
("#<YourDateFieldName>").val(); // set string value }





这会将值从date转换为string并传递字符串。



可能,以下内容不是必需的(我删除了DisplayFormat和ApplyFormatInEditMode,值仍然正确传递):





This will convert value from date to string and pass string.

Possibly, the following is not necessary (I removed DisplayFormat and ApplyFormatInEditMode, and the value was still passed correctly):

[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime? <YourDateFieldName> { get; set; }


@(Html.Kendo().DatePickerFor(model => model.DOB)
         
//The name of the datepicker is mandatory. It specifies the "id" attribute of the widget.
.Value(DateTime.Today) //Set the value of the datepicker
             .Start(CalendarView.Year))





试试此代码



Try this code


这篇关于kendo日期选择器未将选定值传递给控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆