我想将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;
}
}
//的Jscript:
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
});
答案 0 :(得分:0)
你可以试试这个:
vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { ABC = "-1"})";
vrdCurv.replace("-1", datepickerFrom.value());
(脏但我觉得这样可行)
我强烈建议您从启动ASP.NET MVC here开始学习。