Mvc 4 kind of razor don't understand @ Html.Kendo ()

I ran into one problem with Kendo UI server shells in ASP.NET MVC 4. If I use the default .ASPX view, it understands

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

But at the same time, if I try to add a Razor view, he doesn’t understand

 @(Html.Kendo() ) systax.

I also have an entry in web.config

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

Tell me what I am missing and where

Thanks and respect,

Amit

+4
source share
3 answers

To register your Kendo user interface using Razor templates, make sure that your \ Web.config view is shown below.

The bottom of the page also details the setup in the telerik 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>

Web.config.

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

@using Kendo.Mvc.UI ,

+4

Check if the web.config settings are in the View folder (web.config files) and not in the root Web.config

+2
source

Source: https://habr.com/ru/post/1530178/


All Articles