16

I am trying to create a Telerik Grid view but when I go to reference kendo it does not recognize it. Visual Studio is giving me an error when I try to reference kendo. This is the code @(Html.Kendo().Grid) and below is the error.

'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'Kendo' and no extension method 'Kendo' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)

I have added a bundle in the BundleConfig file for both Scripts and Content. Also I have added @Scripts.Render("~/bundles/kendo") and @Styles.Render("/Content/kendo") directly to the razor view.

Many articles that i've read suggest that adding <add namespace="Kendo.Mvc.UI"/> to the Web.Config file would work but it still is throwing out the same error.

Is there something that I am missing?

Brian
  • 427
  • 2
  • 5
  • 16
  • Is `@(Html.Kendo().Grid)` the only line of code you have in the view? Also, it sounds like it might not be finding the Kendo extensions. Have you included a reference to the .dll in your project? – RandomWebGuy Apr 08 '15 at 16:54
  • @RandomWebGuy No I also have the Scripts.Render and the Styles.Render in there. I have tried but I didn't know exactly where to find it. How would I go about including the .dll in my project? – Brian Apr 08 '15 at 17:00
  • Which version of MVC are you using? Have you gone over this document: http://docs.telerik.com/kendo-ui/aspnet-mvc/asp-net-mvc-5 (for your version of MVC) ? It includes a section on including the .dll – RandomWebGuy Apr 08 '15 at 17:09
  • @RandomWebGuy I am clicking on both Browse buttons in the Reference Manager. When I click on the Browse... Button on the botton of the window and it brings up the solution explorer I dont know how to naviaget to the wrappers/aspnetmvc/Binaries/MVC5 – Brian Apr 08 '15 at 17:38
  • The documentation says the default root directory is: `C:\Program Files (x86)\Telerik` try looking there for the wrappers folder and drill down until you find the .dll – RandomWebGuy Apr 08 '15 at 17:45
  • @RandomWebGuy Thank you for all your help! Found the .dll file and now the Razor view recognizes Kendo. – Brian Apr 08 '15 at 17:49
  • @RandomWebGuy That would be no problem at all! – Brian Apr 08 '15 at 17:54

10 Answers10

21

I had the same problem. The third point mentioned below solved the problem in my case.

1. Include the JavaScript and CSS files: The ordering of scripts and css files is also very important. jQuery should be included before the KendoUI script file(s).

2. Add reference to Kendo.Mvc.dll: Right-click the References node in Solution Explorer and click Add Reference. Select the Browse tab of the Add Reference dialog and navigate to the install location of Telerik UI for ASP.NET MVC.

3. Update the web.config in Views folder: Open Views/Web.config (or root Web.config if using ASPX). Locate the namespaces tag. Append an below add tag to the namespaces tag.

<add namespace="Kendo.Mvc.UI" />
AGuyCalledGerald
  • 7,882
  • 17
  • 73
  • 120
vineel
  • 3,483
  • 2
  • 29
  • 33
10

The problem is that you have not included a reference to the Kendo.Mvc.dll. There's an explanation on how to do this in the documentation located here

By default the the root kendo directory is installed at C:\Program Files (x86)\Telerik

RandomWebGuy
  • 1,439
  • 11
  • 23
  • I have the same error, followed all the directions yet it is still giving me the same error. – Mike Aug 10 '17 at 15:06
4

I just added the below line in razor page. Its working for me.

@using Kendo.Mvc.UI;

Ramesh P
  • 81
  • 4
4

For me, it was _ViewImports.cshtml that I needed to edit

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Kendo.Mvc
@using Kendo.Mvc.UI

Now with asp.net core 2.2 the razor page is resolving the @(Html.Kendo()...

Tom Stickel
  • 19,633
  • 6
  • 111
  • 113
  • 1
    This was apparently my problem, for the Tooltip only. Grids worked fine. I had the *, Kendo.Mvc line commented out from when I was playing with the vue version of Kendo since there was a compatibility problem... This only showed up after upgrading to asp.net core 2.2 – Brian MacKay May 13 '19 at 19:50
1

When you created your project you had to have selected the right project type. There is the Telerik asp.net MVC application project type and the Kendo UI Asp.net MVC 5 project type. Picking the Kendo UI project type will provide you with the javascript kendo classes. This is for when you want to use Kendo through javascript, I had the same issue until I went back and chose the right project type. I spent a day and a half trying to add the .net class libraries because my razor wouldn't work. I think Visual studio was just confused about what I was trying to do and I probably was missing a .net class library.

jt25617
  • 21
  • 6
1

Regarding the addition of Kendo into existing ASP Core application, I did find that adding css and javascript (js) file references into my _Layout.cshtml anywhere other than before <environment> tags in the <head> caused an issue. I did eventually get this to work by adding the following:

<link href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.common-material.min.css" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.material.min.css" rel="stylesheet" type="text/css" />

<script src="https://kendo.cdn.telerik.com/2017.2.621/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.2.621/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.2.621/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.2.621/js/kendo.aspnetmvc.min.js"></script>
Adam Cox
  • 3,341
  • 1
  • 36
  • 46
0

Step1: Add Kendo.Mvc.dll to references. You can use the following NuGet gallery command.

Install-Package Kendo.Mvc -Version {yourversion}

Step2: Add the js and css File of Kendo

<link href="@Url.Content("~/Content/kendo/2017.3.1018/kendo.common.min.css")" rel="stylesheet" type="text/css" />

<link href="@Url.Content("~/Content/kendo/2017.3.1018/kendo.mobile.all.min.css")" rel="stylesheet" type="text/css" />

<link href="@Url.Content("~/Content/kendo/2017.3.1018/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />

<link href="@Url.Content("~/Content/kendo/2017.3.1018/kendo.default.min.css")" rel="stylesheet" type="text/css" />

<link href="@Url.Content("~/Content/kendo/2017.3.1018/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" />

<script src="@Url.Content("~/Scripts/kendo/2017.3.1018/jquery.min.js")"></script>

<script src="@Url.Content("~/Scripts/kendo/2017.3.1018/jszip.min.js")"></script>

<script src="@Url.Content("~/Scripts/kendo/2017.3.1018/kendo.all.min.js")"></script>

<script src="@Url.Content("~/Scripts/kendo/2017.3.1018/kendo.aspnetmvc.min.js")"></script>

<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>

Step3: Add the Kendo.Mvc.UI namespace in web.config file.

note: if use the Area in Project you should add this code to web.config of Area.

<system.web>
    <pages>
        <namespaces>
            <add namespace="Kendo.Mvc.UI" />
        </namespaces>
    </pages>
</system.web>
MohammadSoori
  • 2,120
  • 1
  • 15
  • 17
0

However, I had the same problem but it was solved after the following steps:

1- Open tools ==> Extensions and updates
2- Tap on the "Online" tab on the left and search for telerik
3- Download and install "Telerik ASP.NET AJAX VSExtensions" & "Telerik ASP.NET MVC VSExtensions"
4- Close the Window
5- Go to "Telerik" tab
6- Tap on "Telerik UI for ASP.NET MVC"
7- Upgrade Wizard and upgrade

This solved the problem because of the conflict between Telerik versions between two stations. in addition to the fact that kendo is not included in the project if you installed VS after you do for Telerik.

0

AddKendo.Mvc.dll through NugetPackage and Add Kendo.Mvc

Add Namespace in webconfig file

<system.web>
<pages>
    <namespaces>
        <add namespace="Kendo.Mvc.UI" />
    </namespaces>
</pages>

enter image description here

enter image description here

enter image description here

enter image description here

Rock
  • 534
  • 6
  • 14
0

For those who are still facing the same issue, the following link is an updated blog for the latest versions of ASP MVC

Using Telerik in an Existing ASP MVC Project

For ASP MVC 4 Click here

Mussa Moses
  • 101
  • 9