Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 722
Amit Jog Avatar asked Mar 05 '14 07:03

Amit Jog


3 Answers

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>
like image 50
David Avatar answered Oct 23 '22 00:10

David


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

like image 38
Yatin Avatar answered Oct 22 '22 23:10

Yatin


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

like image 34
Nasser Hadjloo Avatar answered Oct 23 '22 00:10

Nasser Hadjloo