How to add Kendo UI HTML helpers to my ASP.net MVC

2020-03-26 04:30发布

问题:

Simple question: I've installed Telerik DevCraft Ultimate on my workstation. I've looked at the examples showing the use of the Kendo UI HTML helpers.

What reference do I add to my project to be able to use them?

回答1:

Configure your ASP.NET MVC layout page to include the Kendo UI Web JavaScript and CSS files:

 <link rel="stylesheet" href="@Url.Content("~/Content/kendo.common.min.css")">
 <link rel="stylesheet" href="@Url.Content("~/Content/kendo.default.min.css")">
 <script src="@Url.Content("~/Scripts/jquery.min.js")"></script>
 <script src="@Url.Content("~/Scripts/kendo.web.min.js")"></script>
 <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>

Add a reference to the Kendo.Mvc.UI namespace to your web.config. Then the Kendo HtmlHelper extension would be availble in your views. Rebuild your project after adding the namespace to the web.config (required for Visual Studio to show intellisense for Kendo.Mvc.UI).

<system.web.webPages.razor>
     <pages pageBaseType="System.Web.Mvc.WebViewPage">
         <namespaces>
             <add namespace="System.Web.Mvc" />
             <add namespace="System.Web.Mvc.Ajax" />
             <add namespace="System.Web.Mvc.Html" />
             <add namespace="System.Web.Routing" />
             <add namespace="Kendo.Mvc.UI" />
         </namespaces>
     </pages>
 </system.web.webPages.razor>

Use any Kendo UI HtmlHelper extension

@(Html.Kendo().DatePicker().Name("Birthday"))

more details at http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/introduction