IHtmlHelper does not contain definition for Kendo .NET 7

1 Answer 569 Views
Installer and VS Extensions
Johannes
Top achievements
Rank 1
Johannes asked on 20 Jul 2023, 10:43 AM

I am using AspNet Core MVC 7

I am trying to create a custom HTML helper outside of a razor view. I am using the IHtmlHelper in this scenario and unfortunately outside of a razor view I cannot do something like this:

var uploader = _helper.Kendo().Upload()
                .Name("uploadFiles")
                .Multiple(true)
                .HtmlAttributes(new { style = "margin: 15px 0 5px 0;" });

Compilation error:


Error CS1061 'IHtmlHelper' does not contain a definition for'Kendo'

and no accessible extension method 'Kendo' accepting a first argument of

type'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)


 

1 Answer, 1 is accepted

Sort by
1
Alexander
Telerik team
answered on 25 Jul 2023, 05:15 AM

Hi Johaness,

Thank you for reaching out.

Generally, the HtmlHelper is an ASP.NET Core View feature that its purpose is to only reside within the existing View layer of the application due to the MVC architecture pattern as a whole rather than be stored within a separate Action Method on the Controller layer.

Normally such an error will be observed within the view if the "Kendo.Mvc.UI" assembly is not referred to. For example:

@using Kendo.Mvc.UI

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Installer and VS Extensions
Asked by
Johannes
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or