This is a migrated thread and some comments may be shown as answers.

Error while using Editor

2 Answers 831 Views
Editor
This is a migrated thread and some comments may be shown as answers.
fery
Top achievements
Rank 1
fery asked on 10 Oct 2019, 11:59 AM

Hi

please help me how to use Kendo Editor Template

this is my code:

Product Model:

[UIHint("RichText")]
 
public string ProductDescription { get; set; }

 

RichText EditorTemplate

@model string
 
@* Make sure tag helpers are not available for the Editor content *@
@removeTagHelper "*, Microsoft.AspNet.Mvc.Razor"
@removeTagHelper "*, Microsoft.AspNetCore.Mvc.Razor"
 
@(Html.Kendo().EditorFor(mo => mo).Encoded(false)
          .Name("editor")
          .HtmlAttributes(new { style = "height:440px", aria_label = "editor" })
          .Resizable(resizable => resizable.Content(true).Toolbar(true))
          .ImageBrowser(imageBrowser => imageBrowser
              .Image("~/Shared/UserFiles/Images/{0}")
              .Read("Read", "ImageBrowser")
              .Create("Create", "ImageBrowser")
              .Destroy("Destroy", "ImageBrowser")
              .Upload("Upload", "ImageBrowser")
          )
 
    )

 

usage in View:

@Html.EditorFor(m => m.ProductDescription)

 

but I get Error below:

An unhandled exception occurred while processing the request.
InvalidOperationException: You cannot override component name when bound to a model expression.
Kendo.Mvc.UI.Fluent.WidgetBuilderBase<TViewComponent, TBuilder>.Name(string componentName)

 

 

InvalidOperationException: You cannot override component name when bound to a model expression.
Kendo.Mvc.UI.Fluent.WidgetBuilderBase<TViewComponent, TBuilder>.Name(string componentName)
AspNetCore.Views_Shared_EditorTemplates_RichText.ExecuteAsync() in RichText.cshtml
+
@(Html.Kendo().EditorFor(mo => mo)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateRenderer.Render()
Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateBuilder.Build()
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.GenerateEditor(ModelExplorer modelExplorer, string htmlFieldName, string templateName, object additionalViewData)
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper<TModel>.EditorFor<TResult>(Expression<Func<TModel, TResult>> expression, string templateName, string htmlFieldName, object additionalViewData)
Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperEditorExtensions.EditorFor<TModel, TResult>(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
AspNetCore.Areas_Users_Views_Products_Edit.<ExecuteAsync>b__24_0() in Edit.cshtml
+
                @Html.EditorFor(m => m.ProductDescription)
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.GetChildContentAsync(bool useCachedResult, HtmlEncoder encoder)
Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, int i, int count)
AspNetCore.Areas_Users_Views_Products_Edit.ExecuteAsync() in Edit.cshtml
+
    Layout = "~/Areas/Users/Views/Shared/_Layout.cshtml";
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|21_0(ResourceInvoker invoker, IActionResult result)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

2 Answers, 1 is accepted

Sort by
0
fery
Top achievements
Rank 1
answered on 10 Oct 2019, 06:38 PM

And one more question

Kendo Editor not decode Html

i use this:

@(Html.Kendo().EditorFor(mo => mo).Encoded(false)

0
Ivan Danchev
Telerik team
answered on 15 Oct 2019, 11:58 AM

Hello,

When an EditorFor helper is used it takes its name from the model field (in this case ProductDescription) it is bound to, so its Name configuration should not be set. Name is required if you are using the Editor helper, since it is not bound to a model field, e.g.:

@(Html.Kendo().Editor()
	.Name("editor")
	//... additional configuration
)

With regard to the issue you are having with the Encoded option, could you post an exemplary value you pass to the Editor?

Regards,
Ivan Danchev
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.
Tags
Editor
Asked by
fery
Top achievements
Rank 1
Answers by
fery
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or