mvc 4 razor view do not understand @Html.Kendo()

15,448

Solution 1

To register Kendo UI using Razor templates make sure you have the below in your Views\Web.config.

Towards the bottom of the page also details the setup in telerik's documentation.

http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/asp-net-mvc-4

<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="System.Web.Mvc" />
            ...
            <add namespace="Kendo.Mvc"/>
            <add namespace="Kendo.Mvc.UI"/>
        </namespaces>
    </pages>
</system.web.webPages.razor>

I also have the below in my main Web.config file.

<system.web>
    <compilation debug="true" targetFramework="4.5">
        <assemblies>
           ...
            <add assembly="Kendo.Mvc"/>
        </assemblies>
    </compilation>
</system.web>

Solution 2

Adding @using Kendo.Mvc.UI at the top of the page and it worked for me

Solution 3

Check if your web.config settings is in the View Folder ( web.config files) not the root Web.config

Share:
15,448
Amit Jog
Author by

Amit Jog

Updated on June 20, 2022

Comments

  • Amit Jog
    Amit Jog almost 2 years

    I am facing one problem with Kendo UI server wrappers in ASP.NET MVC 4 If I use .ASPX default view It understands the

     <%: Html.Kendo().Grid() %> 
    

    But at the same time If I try to add Razor view It do not understand

     @(Html.Kendo() ) systax.
    

    I have entry in web.config as well

    <namespaces>
    <add namespace="Kendo.Mvc.UI" />
    
    
    <httpHandlers>
          <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
      </httpHandlers>
    
     <handlers>
      <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd"  type="Telerik.Web.UI.WebResource" />
    

    Pl tell me what I must be missing and where

    Thanks and Regards,

    Amit

  • Amit Jog
    Amit Jog about 10 years
    already had the <system.web.webPages.razor> tag but Kendo namespaces were not there..just added...SOLVED...THANKS
  • Yatin
    Yatin about 8 years
    @ChuckKrutsinger - I added it to my view.