Kendo UI reference not working in Razor view

Brian picture Brian · Apr 8, 2015 · Viewed 38.8k times · Source

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?

Answer

vineel picture vineel · Aug 7, 2015

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" />