ASP.NET Core & JavaScript

2 posts, 1 answers
  1. Joel
    Joel avatar
    209 posts
    Member since:
    Jun 2018

    Posted 19 Nov 2018 Link to this post

    I've been a developer for a long time.  I've also been avoiding JavaScript for a long time.  If I'm going to learn ASP.NET Core and use Telerik controls, how much JavaScript must I learn?

    When I open the Kendo.Mvc.Examples and look in the wwwroot.lib Folder, I get quite overwhelmed with the sheer number of .js files there.   

    I have created a web site utilizing Razor pages and that was quite intuitive.  I can use C# syntax on the pages and the MVC methodologies are easy to follow.  But now, I am attempting to use the Telerik Kendo TreeView and I am bogged down into trying to figure out what script(s) I'm missing in order to get this to work right.  

    So, does this mean there is no way I'm going to avoid JavaScript in order to use Telerik Kendo controls.  If not, I need some directions where to start.  There is way to much in the environment to take it all in at once.  Do I need to starting drinking JavaScript from a fire hose in order to get this working?

    Thanks in advance for your help,

    Joel

  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    5905 posts

    Posted 21 Nov 2018 Link to this post

    Hi Joel,

    The UI for ASP.NET Core suite is a set of server-side wrappers for the Kendo UI for jQuery widgets. This means that in the end you basically get the jQuery widgets, but you generate them through C# (Razor) syntax and properties and not through a JavaScript literal with options. You can read more on the difference in the following article: https://docs.telerik.com/aspnet-mvc/getting-started/kendo-ui-vs-mvc-wrappers.

    This means that to get them to work, you must, basically, be able to get the jQuery widgets to work. To do that, you need various web assets that include JavaScript files, stylesheets, fonts and images.

    The good news is that you don't need all of the files you have seen in the lib folder.

    What you see in our demos is just the full collection of granular files that one can use. For example, if you only want to use a numeric textbox, there isn't much sense in carrying the scripts for, let's say, the scheduler. This granular approach requires maintenance on part of the developer and to follow what resources you need to include (see here for more details on this approach). The availability of those files is a feature that allows developers fine-grained control, because some people want it.

    The easy way to go, however, only requires a few files:

    • jQuery - the basic "framework"
    • kendo.all.min.js - that's the file containing just about all scripts for all cases so you can instantiate all widgets with it
    • kendo.aspnetmvc.js - that's the file that adds some helpers related to translating the razor syntax into the jQuery syntax
    • the common styles and a theme with its surrounding assets (images, fonts, more details are available in a link you will find below)
    • the Kendo.Mvc.dll assembly.

    The way to get the assembly is through the NuGet package that will add the reference for you. To add the client resources, see the last article in the bullet list below.

    You can read more about including the various assets in the following articles, and I recommend you review them so you can better understand how the widgets work and what you need:

    Regarding using JavaScript - widget customization and responding to events is still done through JavaScript, so if you need anything more than declaring the widgets - like creating custom templates, or responding to user actions - you're going to need some JavaScript to do that.

    Ultimately, the pages you get from the views with the Kendo widgets are code that will run in the browser, and the language there is JavaScript for any interaction, even if you can declare things on the server with markup/C# for the initial response.

    So, some understanding of the underlying jQuery widgets is necessary, more so if you will be customizing their behavior, yet not everything is done with JavaScript, and you do not need all of those files.


    Regards,
    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top