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

Editor Postback issue in EditorTemplate

2 Answers 103 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 03 Dec 2012, 09:38 AM
I've got a Grid with a Custom popup template that contains an Editor control. When clicking the update button with HTML the page doesn't close and when debugging the controller action the breakpoint is never hit as an exception occurs during model binding (I think). When just entering plain text with no markup the model binding works correctly, the window closes and everything is peachy. I've attached a sample project to demonstrate. Try saving with just normal text and then try using HTML in the editor.
Any resolution\work around\ explanation of what I'm doing wrong would be appreciated.

Rob

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 05 Dec 2012, 08:47 AM
Hello Rob,

MVC throws an exception for potentially dangerous request when a value contains HTML tags. To specify that this is allowed for a property and avoid the exception you should use the AllowHtmlAttribute on the property:

public class SampleModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    [AllowHtml]
    public string HTMLContent { get; set; }
}
Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Robert
Top achievements
Rank 1
answered on 05 Dec 2012, 12:19 PM
Doh! Thanks very much Daniel. Worked a treat.
Tags
Editor
Asked by
Robert
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Robert
Top achievements
Rank 1
Share this question
or