Bootstrap 日期选择器传递给 c# ajax 调用

Bootstrap datepicker passing to c# ajax call

我无法将日期传递给 ajax 通话。日期来自 bootstrap 日期时间选择器。我确实通过使用 javascript 获得了价值:

 var DateFrom = $("#dpDateFrom").data('datepicker').date;

我通过从数据表调用 ajax 来传递这个日期。

 tblActivity = $('#tblActivity').dataTable({
    "oLanguage": { "sEmptyTable": "No data to display" },
    "bJQueryUI": false,
    "bAutoWidth": false,
    "sAjaxSource": '/api/activitylogapi/Activityt',
    "aaData": mainJson.aaData,
    "bProcessing": false,
    "bServerSide": true,
    "bSort": true,
    "bFilter": false,
    "bRetrieve": true,
    "aoColumns": [
                 { "sTitle": "Activity Type", "mDataProp": "Type", "sWidth": "10%" },
                 { "sTitle": "Comments", "mDataProp": "Comments", "sWidth": "10%" },
                 { "sTitle": "Company Name", "mDataProp": "CompanyName", "sWidth": "10%" },
                 { "sTitle": "Contact", "mDataProp": "Contact", "sWidth": "10%" },
                 { "sTitle": "User", "mDataProp": "UserFullName", "sClass": "truncate", "sWidth": "10%" },
                 { "sTitle": "Created", "mDataProp": "DateS", "sClass": "text-right", "sWidth": "10%" },

    ],
    "iDeferLoading": [mainJson.count, mainJson.count],
    "aoColumnDefs": [{ "bSortable": false, "aTargets": [1,2,3,5] }],
    "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
        aoData.push({ "name": "DateFrom", "value": DateFrom });
        aoData.push({ "name": "DateTill", "value": DateTill });

        doDataTablePostAjaxCalling(this, sSource, aoData, fnCallback, oSettings);
    },
    "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {            
    }

我的 ajax 调用需要 DateTimeOffset 但无法获得成功通过的日期。有没有办法让我确定我的 javascript 日期

我通过使用 .val() 从日期选择器获取值解决了这个问题。然后在 javascript 中创建一个日期对象,然后将其传递给我的控制器。