EdWood
EdWood

Reputation: 907

Kendo, ASP.NET Core - Uncaught ReferenceError: kendo is not defined

I have started using Kendo + ASP.NET Core. I followed this tutorial http://docs.telerik.com/aspnet-core/getting-started/getting-started#configuration-Add, but I got error: Uncaught ReferenceError: kendo is not defined.

HEAD

    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="/css/site.css" />
    <link rel="stylesheet" href="/lib/kendo-ui/styles/kendo.common-nova.min.css" />
    <link rel="stylesheet" href="/lib/kendo-ui/styles/kendo.nova.min.css" />

BODY

<h2>Kendo UI DatePicker</h2><input id="datepicker" name="datepicker" type="text" value="" /><script>kendo.syncReady(function(){jQuery("#datepicker").kendoDatePicker({"format":"dd.MM.yyyy","footer":false});});</script>
    <script src="/lib/jquery/dist/jquery.js"></script>
    <script src="/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="/js/site.js?v=EWaMeWsJBYWmL2g_KkgXZQ5nPe-a3Ichp0LEgzXczKo"></script>
    <script src="/lib/kendo-ui/js/kendo.all.min.js"></script>
    <script src="/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>

Upvotes: 2

Views: 3396

Answers (1)

Win
Win

Reputation: 62260

If I use Kendo UI in ASP.NET Core, I personally like to place all those scripts inside head tag.

Since there are too many code in ASP.NET Core, I keep them in separate Partial class. For example, _StylesScriptsPartial.cshtml

<environment names="Development">
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css"/>
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.bootstrap.min.css" />
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.common-bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css"/>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
    <script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/lib/kendo-ui/js/kendo.all.min.js"></script>
    <script src="~/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
</environment>

Inside _layout.cshtml,

@await Html.PartialAsync("_StylesScriptsPartial")

Another trick is adding Kendo UI as Local NuGet Package make a lot easier than manually referencing DLLs.

Add NuGet Packages

enter image description here

Upvotes: 6

Related Questions