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

Html text decoded value issue

3 Answers 678 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Enrico
Top achievements
Rank 1
Enrico asked on 06 Mar 2012, 03:08 PM
Hi there,

i'm having an unexpected behavior using the property "encoded" of kendoEditor control. The problem is that string returned into my controller is an html encoded string doesn't matter if the value is set to true or false.

In order to save the correct value into the database, i need to use an helper to decode the value.

WebUtility.HtmlDecode(returnModel.TextValue);

Is there any way to have the html decoded string on my posted model?

Thanks in advance,
Enrico

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 Mar 2012, 10:20 AM
Hello Enrico,

I cannot reproduce the described problem locally.

Generally, the value of the encoded property is taken into consideration when the <form> in which the Editor is placed, is submitted. In the Editor's initialization method, it searches for a parent <form> and binds to its submit event. When the form is submitted, the Editor checks its encoded property and saves a (non-)encoded string to its hidden <textarea> element.

A problem with this setup may occur if the form is submitted with Javascript. In this case you should submit with jQuery, which will trigger the submit event manually:

http://api.jquery.com/submit/

Note that submitting non-encoded value will cause a server-side exception from the ASP.NET framework, unless you disable request validation.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Enrico
Top achievements
Rank 1
answered on 07 Mar 2012, 09:13 PM
Hi Dimo,

thanks for the replay. I'm using an ajax POST action to an ASP.NET MVC 3 controller. On this controller i did previously disabled ValidateInput for avoiding exception issues.

I've a jquery dialog with a button who's in charge to call the save method (inside the data-action-save attribute i have the url action method to call)

var data = $("#customerEditForm").serialize();

Save(data);

function Save(model) {
    $.ajax({
        type: "POST",
        url: $("#customerEditItem").data("action-save"),
        data: model,
        dataType: "json",
        ... other staff in here ...
        }
    });

When the model is binded back to the controller on my text field I've the encoded html string.

Any suggestion?
0
Dimo
Telerik team
answered on 08 Mar 2012, 08:34 AM
Hi Enrico,

You can call the Editor's update() method (with no parameters) before triggering the Ajax request. This is what the Editor normally does on form submit to update its hidden <textarea> value, according to the encoded property.

Kind regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Editor
Asked by
Enrico
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Enrico
Top achievements
Rank 1
Share this question
or