opening text with markup Editor

1 Answer 198 Views
Editor
Вадим
Top achievements
Rank 1
Iron
Iron
Вадим asked on 12 Jan 2022, 06:58 PM

available Editor with model @model:


@model service.Models.ServiceViewModel
@(Html.Kendo().Editor()
            .Name("Description")
            .Tools(tools => tools
                .Clear()
                .Bold().Italic().Underline()
                .JustifyLeft().JustifyCenter().JustifyRight()
                .InsertUnorderedList().InsertOrderedList()
            )
            .StyleSheets(css => css
                .Add(Url.Content("~/shared/web/editor/editorStyles.css"))
            )
            .Value(@<text></text>)
            .HtmlAttributes(new { style = "width: 100%;height:400px" })
        )


public class ServiceViewModel
    {
********
        public string Description { set; get; }
*****
}

I save the data to the database.
When I pull the data to correct, the data is shown without markup.
At the same time, the data is saved as:

"&lt;p&gt;1&lt;/p&gt;&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;3&lt;/em&gt;&lt;/p&gt;"

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 17 Jan 2022, 01:30 PM

Hi Вадим,

Thank you for sharing the available data in the ServiceViewModel.

This error is caused by the encoding of the data when it is sent to the server. To properly format html strings the Editor needs them to be unencoded:

<p>1</p><p><strong>2</strong></p><p><em>3</em></p>
To achieve this set the Editor's encoded property to false
.Encoded(false)
and configure your model to not encode the Html string on the server-side. For more information refer to the Displaying Raw Html section of the Editor's Troubleshooting Documentation.

I hope the information above is useful. Please let me know, if further questions occur.

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Editor
Asked by
Вадим
Top achievements
Rank 1
Iron
Iron
Answers by
Stoyan
Telerik team
Share this question
or