(MVC 3 app)
Whenever I post a form with an editor on it, the content stored in my viewmodel is encoded.
The start of my test is with <p>Test</p> stored in the database.
When the content is edited for the first time, it is displayed OK.
When I click on my save button, and the data is posted. In the viewmodel in my controller I already see : %3Cp%3ETest%3C/p%3E
This value is stored in the database and the next time I want to edit the record, this text is shown as stored : %3Cp%3ETest%3C/p%3E
I have to say, to get this editor working in my environment I spent hours... It is an existing application, and all data editing is done in a modal dialog by means of a partial view.First of all, the MVC helper did not fill in the content at all. And then when doing it with setContent, I always got an error on .contentWindow
I made it work with the following :
$.ig.loader(function () { var heditor = $("#igTemplateHTML"); var frame = $("iframe", heditor).get(0); var editorContent = "@Model.TemplateHTML"; $(heditor).igHtmlEditor("setContent", editorContent, "html"); });
Part of the code where the editor is used.
<script src="@Url.Content("scripts/infragistics/infragistics.loader.js")"></script>
@Html.Infragistics().Loader().ScriptPath(Url.Content("scripts/infragistics")).CssPath(Url.Content("Content/infragistics")).Render()
@using (Ajax.BeginForm(ajaxOptions, "editFormTemplate")){@Html.ValidationSummary()<div>@Html.HiddenFor(model => model.Id)@Html.EditorLineFor(model => model.TemplateNL, true)@Html.Infragistics().HtmlEditorFor(model => model.TemplateHTML).ID("igTemplateHTML").Width("800px").Height("500px").Render()</div>}
It would be good in your MVC example comment something about this. There are many lost hours with this problem.
http://help.infragistics.com/Help/Doc/jQuery/2013.2/CLR4.0/html/igHtmlEditor_Saving_HTML_Content.html#mvc_define_model
Thanks!
Hi Ronny Houben,
Thank you for posting in our forum.
Please let us know if you have any other questions.
Sincerely,
Deyan Kamburov
Hi there,
The igHtmlEditor is performing encodeURI() on the content, because if it's not then there would be security exceptions when submitting a form that contains the igHtmlEditor. You can perform decodeURI() on the client and the equivalent on the server in order to get the non-encoded content. Keep in mind that it's HTML and scripts can be injected.
Thank you for using the Infragistics forums!