无法在VS 2012中将kendo UI集成至MVC4

3

我正在使用VS 2012尝试集成Kendo UI。 我已经安装了nuget“Kendo UI”,并且在_Layout.cshtml中引用了它。

 <link rel="stylesheet" href="@Url.Content("~/Content/kendo/2013.2.716/kendo.common.min.css")">
<link rel="stylesheet" href="@Url.Content("~/Content/kendo/2013.2.716/kendo.default.min.css")">
<script src="@Url.Content("~/Scripts/kendo/2013.2.716/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2013.2.716/jquery.min.js")"></script>

当我尝试创建新视图时,Kendo不支持。
如果我在customerdetail.cshtml中写入以下代码:
@(Html.Kendo().Grid<KendoUIDemo.Models.Customer>()
  .Name("grid")
  .DataSource(dataSource => dataSource // Configure the grid data source
      .Ajax() // Specify that ajax binding is used
      .Read(read => read.Action("CustomerDetail", "Home")) // Set the action method which will return the data in JSON format
   )
  .Columns(columns =>
  {
      // Create a column bound to the ProductID property
      columns.Bound(product => product.ProductID);
      // Create a column bound to the ProductName property
      columns.Bound(product => product.ProductName);
      // Create a column bound to the UnitsInStock property
      columns.Bound(product => product.UnitsInStock);
  })
  .Pageable() // Enable paging
  .Sortable() // Enable sorting

错误:-“System.Web.Mvc.HtmlHelper”不包含“Kendo”的定义,也没有找到接受类型为“System.Web.Mvc.HtmlHelper”的第一个参数的扩展方法“Kendo”(是否缺少使用指令或程序集引用?)

请问我已经在视图的web.config中添加了引用,有任何想法吗? 提前感谢!!

2个回答

3
请参阅文档以获取初始设置指南 - http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/introduction
在您的Web项目\Views\Web.config文件中,请检查是否添加了Kendo.Mvc和Kendo.Mvc.UI作为命名空间。
<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        ...
        <add namespace="Kendo.Mvc"/>
        <add namespace="Kendo.Mvc.UI"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

在您的 Web 项目\Web.config 文件中,您可能需要以下内容。
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
        </dependentAssembly>
        ....

还要检查您的项目引用,以便您拥有对它们的引用

Kendo.Mvc
System.Web.Helpers

嗨David,我刚安装了最新版本并构建了它,但是在视图的Web配置文件以及主Web.config中找不到这样的命名空间。 - Parth Mehta
如果仍然显示相同,请重新启动并卸载项目,然后再次加载。 - Vivekh

1

您需要下载其安装程序(最新版本: kendoui.aspnetmvc.2013.2.918.commercial.msi),然后安装它。这不是完全通过NuGet软件包完成的,因此您会收到错误消息。(Bhai tamare kendo nu latest version nuget package mathi nai installer through download karvu padshe.)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接