我收到ASP.NET MVC的“预期”错误

时间:2019-02-03 15:26:27

标签: asp.net-mvc

我是编程新手。我一直收到这个EXPECTED错误。

我所附的屏幕截图显示了带有红色标记的EXPECTED错误:

Screenshot

索引:

@{
    ViewBag.Title = "Index";
}

<h2>Part 1 : Implement jQuery Datatable in ASP.NET MVC</h2>
<div style="width:90%; margin:0 auto;">
    <table id="myTable">
        <thead>
            <tr>
                <th>Employee Name</th>
                <th>Long Des</th>
                <th>Col Div</th>
                <th>Job Title</th>
                <th>Tenure Dec</th>
                <th>Emp Start</th>
            </tr>
        </thead>
    </table>
</div>
<style>
    tr.even {
        background-color: #F5F5F5 !important;
    }
</style>
@* Load datatable css *@
<link href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet" />
@* Load datatable js *@
@section Scripts{
    <script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
    <script>
        $(document).ready(function () {
            $('#myTable').DataTable({
                "ajax": {
                    "url": "/home/loaddata",
                    "type": "GET",
                    "datatype": "json"
                },
                "columns": [
                        { "data": "L_FNAME", "autoWidth": true },
                        { "data": "COL_DIV_CODE", "autoWidth": true },
                        { "data": "JOB_TITLE", "autoWidth": true },
                        { "data": "TENURE_DEC_YR_MO", "autoWidth": true },
                        { "data": "EMPT_START_DATE", "autoWidth": true },
                        { "data": "BASE", "autoWidth": true },
                        { "data": "YTD", "autoWidth": true }
                ]
            });
        });
    </script>
}

Homecontroller.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MVCDatatable.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult loaddata()
        {
            using (MydatabaseEntities dc = new MydatabaseEntities())
            {
                var data = dc.Employees.OrderBy(a => a.L_FNAME).ToList();
                return Json(new {data = data}, JsonRequestBehavior.AllowGet);
            }
        }

问题出在家庭控制器中。该}导致EXPECTED错误。

这是一项家庭作业。

1 个答案:

答案 0 :(得分:0)

您错过了几个字符。数一下牙套;请注意,./a.out BEFORE: 0.0000000000000000 AFTER: 0.0000000000000000 REAL*8 FUN多得多-如果发布的代码正是您所拥有的代码(无复制和粘贴错误),则您永远不会关闭类或命名空间范围。该错误消息实际上会显示prog.f,它告诉您它希望接下来看到一个./a.out BEFORE: 0.0000000000000000 AFTER: 110.00000000000000 ,但是却找到了文件的末尾。

添加一个{结束类,并添加另一个}结束名称空间范围,您的代码将被编译。