Use an Inline Editor in Editor Templates
Environment
Product | Telerik UI for ASP.NET Core Editor |
Progress Telerik UI for ASP.NET Core version | 2024.4.1112 |
Description
How can I use an inline Editor in an editor template and submit its value?
Solution
When you add the inline Editor component in a form through an ASP.NET Core Editor template, its value will not be posted with the form. The reason for that is the inline mode that renders a DOM element, which is not a form field. Therefore, the value is not submitted with the form. To handle this scenario, customize the Editor template by adding a hidden input and update it when the content of the Editor changes.
@model string
@(Html.Kendo().EditorFor(model => model)
.Name(Html.NameFor(model => model) + "_Editor")
.Tag("div")
.Tools(tools => tools.Clear().Bold().Italic().Underline())
.Events(events => events.Change(@"function (ev){
var hiddenInput = $('#" + Html.NameFor(model => model) + @"');
hiddenInput.val(ev.sender.value());
hiddenInput.change();
}"))
)
@Html.HiddenFor(model => model)