I want to transfer datetimepicker value to my controller. I am able to transfer value by regular:
//PassDate Value While Calling Main Controller.
vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { ABC = "asdnfsdf" })";
But not able to get result from the below code.
//******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 })";
//Controller Code:
[HttpGet]
public JsonResult GetOutgoingMessage(string ABC)
{
var a = abc;
}
I also tried to pass normal variable value as below code that is also not working:
[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
});
Can you try this:
vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { ABC = "-1"})";
vrdCurv.replace("-1", datepickerFrom.value());
(dirty but I think this will work)
I strongly recommend you to go start learning from start ASP.NET MVC here.