我想将 datetimepicker 值传输到我的控制器。我可以定期转移价值:
//PassDate Value While Calling Main Controller.
vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { ABC = "asdnfsdf" })";
但无法从下面的代码中得到结果。
//******Start of Date Pickers************
var datepickerFrom = $("#dateFromPicker").kendoDatePicker({
format: "dd/MM/yyyy",
change: function () {
datepickerTo.min(datepickerFrom.value());
},
}).data("kendoDatePicker");
//PassDate Value While Calling Main Controller.
vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { dateTimePicker.value })";
//控制器代码:
[HttpGet]
public JsonResult GetOutgoingMessage(string ABC)
{
var a = abc;
}
我还尝试传递正常的变量值,如下代码也不起作用:
[HttpGet]
public JsonResult GetOutgoingMessage(DateTime? abc)
{
using (var db = SiteUtil.NewDb)
{
TempData["msg"] = abc;
}
}
//脚本:
var fromDate = null;
var toDate = null;
//Inilialise date variable.
fromDate = '2015-07-10';
toDate = '2015-07-10';
var dataSourceOutMessage = new kendo.data.DataSource({
transport: {
read: {
url: "@Url.Action("GetOutgoingMessage", "OutGoingMessages")",
dataType: 'json',
date:{"fromdate" : fromdate}
}
},
schema: {
model: {
fields:
{
Id: { type: "String" },
MsgType: { type: "String" },
Subject: { type: "String" },
CreatedOn: { type: "String" },
ProcessedOn: {type: "date"}
}
}
},
pageSize: 20
});