@(Html.Kendo() 不被智能感知识别

@(Html.Kendo() is not recognised by intellisense

我正在使用 Kendo.Mvc dll,下面是我的 .cshtml

    @using Kendo.Mvc.UI
    @model SupplierPortal.RedirectionApp.Models.SiteDetailViewModel
    @using System.Web.Optimization
    @{
        ViewBag.Title = "Index";
        Layout = null;
    }
<script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script>
@*<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.20/jquery-ui.min.js" type="text/javascript"></script>*@
@*<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.714/styles/kendo.common-bootstrap.min.css" />*@
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common-bootstrap.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.bootstrap.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.mobile.min.css" />
<script src="//kendo.cdn.telerik.com/2016.2.714/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.2.714/js/kendo.aspnetmvc.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <div>
        @(Html.Kendo().Grid<SupplierPortal.RedirectionApp.Models.SiteDetailViewModel>()
                      .Name("Grid")
                      .Columns(columns =>
                      {
                          columns.Bound(p => p.name).Title("Name");
                          columns.Bound(p => p.gender).Title("Gender");
                          columns.Bound(p => p.designation).Title("Designation").Width("300px");
                          columns.Bound(p => p.department).Title("Department").Width("300px");
                      })

                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                      .Navigatable()
                      .Pageable()
                      .Sortable()
                      .Scrollable()
                      .DataSource(dataSource => dataSource // Configure the grid data source
                      .Ajax()
                      .Model(model =>
                      {
                          //model.Id(x => x.id);
                      })
                          .Read(read => read.Action("Employee_Read", "Home")) // Set the action method which will return the data in JSON format
                       )
        )
    </div>

下面是我的控制器

public ActionResult Index([DataSourceRequest]DataSourceRequest request)
{
    string nasaUserId = "vlc00072";
    var _prd = _redirectionService.GetSiteDetailsForAppUser(nasaUserId);
    _siteDetailViewModel.SiteDetailList = _prd;
    return Json(_siteDetailViewModel, JsonRequestBehavior.AllowGet);
}

我还在 Views Web.Config 中添加了 Kendo.MVC 参考,如下所示

<namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="SupplierPortal.RedirectionApp" />
    <add namespace="Kendo.Mvc" />

</namespaces>

并在主 web.config 文件中

  <system.web>   
<compilation debug="true" targetFramework="4.5.2" >
<assemblies>       
    <add assembly="Kendo.Mvc" />
  </assemblies>
</compilation>
<httpRuntime targetFramework="4.5.2" />
<httpModules>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>

谁能告诉我哪里做错了以及为什么 razor 不能识别 @Html.Kendogrid() 并且我还在参考中包含了 dll。

您必须使用 Telerik 团队提供的 Kendo.mvc.dll。我通过从 nuget 安装 Kendo.MVC 遇到了同样的问题,但它没有识别然后我添加了 Telerik 团队给出的 .dll。现在它正在工作。 Here is the link 下载试用版,您会在 C:\Program Files (x86)\Telerik\UI 中找到 Kendo.Mvc.dll for ASP.NET MVC Q2 2016\wrappers\aspnetmvc\Binaries安装后的位置。