0

我想将 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
   });
4

1 回答 1

0

你可以试试这个:

 vrdCurv = "@Url.Action("GetOutgoingMessage", "OutGoingMessages", new { ABC = "-1"})";
 vrdCurv.replace("-1", datepickerFrom.value());

(很脏,但我认为这会起作用)

我强烈建议你从这里开始学习 ASP.NET MVC 。

于 2015-09-04T07:39:56.420 回答