Editor Postback issue in EditorTemplate

3 posts, 1 answers
  1. Robert
    Robert avatar
    4 posts
    Member since:
    Nov 2012

    Posted 03 Dec 2012 Link to this post

    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. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 05 Dec 2012 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Robert
    Robert avatar
    4 posts
    Member since:
    Nov 2012

    Posted 05 Dec 2012 Link to this post

    Doh! Thanks very much Daniel. Worked a treat.
Back to Top