无效的JSON原语:日期

时间:2018-08-07 17:11:24

标签: c# html json json.net

我不断收到以下错误:“无效的JSON原语:日期”。我不确定该如何纠正,因为我对项目的前端/后端进行了更改。除了调试JavaScript以外,其他一切似乎都可以正常工作。我的前端代码如下(我只包含一些使用日期的HTML):

 <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" 
    runat="server">
   <script>
    $("#Grid").kendoGrid({
            "dataSource": {
                "transport": {
                    "read": {
                        "url": "CreateReq.aspx/PopulateMessages",//page then function
                        contentType: "application/json; charset=utf-8", 
                        type: "GET",
                        dataType: "json",
                        "data": {
                            requestID: document.getElementById("lblRequestID").textContent
                        } 
                    },
                    create: {
                        url: "CreateReq.aspx/CreateMessage",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        "data": {

                        }

                    },
                    "prefix": ""
                },
                "schema": {
                    data: function (response) {
                        return response.d;
                    },
                    model: {
                        fields: {
                            Date: { type: "date",editable: false, format: "{0: MM/dd/yyyy}", encoded: true, /*defaultValue: Date.now*/ },
                            Author: { type: "string", editable: true},
                            Message: { type: "string" }, 

                        }

                    }
                },
            },
            //pageable: true,
            height: 225,
            toolbar: ["create"],
            columns: [

                { field: "Date", title: "Date", width: "75px", /*template: '#= kendo.toString((Date), "MM/dd/yyyy")#'*/ format: "{0: MM/dd/yyyy}", encoded: true},
                { field: "Author", title: "Author", width: "75px" },
                { field: "Message", title: "Message", width: "300px" },
                { command: ["edit", "destroy"], title: "&nbsp;", width: "250px" }],
            editable: "inline"
        });
    });

</script>

<h1 style="text-align: center">Academic Code Request</h1>
<div class="TopPageButtons" style="text-align: center">

        <br />
</div>

<div class="TrackingBox">
    <div class="TrBoxContent">
        <div>
            <label><b>ID</b></label><br />
            <asp:Label ID="lblRequestID" Text="" runat="server" ClientIDMode="Static"/>
        </div>

        <div>
            <label><b>Form View Date</b></label><br />

            <asp:TextBox ID="RequestDate" runat="server" ClientIDMode="Static" style="text-align:center"/>
            <script>
                document.getElementById("RequestDate").value = new Date().toString();
            </script>
        </div>

0 个答案:

没有答案