newline - data not saved

3 posts, 1 answers
  1. Terje
    Terje avatar
    9 posts
    Member since:
    Feb 2011

    Posted 29 May 2013 Link to this post

    Anybody experienced this using Kendo UI Editor?

    When typing a lot of text without a newline (Enter-button) everything saves just fine, but if anybody press the enterbutton to make the text more readable, the data just does not get saved. Being newbie on both mvc and kendo, I really need help getting past this problem..

    Using OpenAccess ORM.

    Thanks in advance.
    public partial class Exercises
    {
    private string _note;
    public virtual string Note
    {
    get { return this._note; }
    set { this._note = value; }
    }
    }
    Exercise.Note = drill.Comments;
    DB.SaveChanges();
    <div class="editor-label">
        @Html.LabelFor(m=>m.Comments)
    </div>
    <div class="editor-field">
        @Html.EditorFor(m=>m.Comments)
        @Html.ValidationMessageFor(m=>m.Comments)
    </div>
    [Display(Name = "Comments", ResourceType = typeof(DisplayNameStrings)), UIHint("Editor")]
            public string Comments { get; set; }
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 31 May 2013 Link to this post

    Hello,

    The problem could be caused by an exception thrown on the server for dangerous request. When pressing enter, HTML tags will be added to the value and MVC will thrown an exception if the editor encoding is disabled. If that is the case, then you could use the AllowHtml attribute on the model property to specify that HTML is allow for the field:

    [Display(Name = "Comments", ResourceType = typeof(DisplayNameStrings)), UIHint("Editor"), AllowHtml]
    public string Comments { get; set; }
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Terje
    Terje avatar
    9 posts
    Member since:
    Feb 2011

    Posted 10 Jul 2013 Link to this post

    That did the trick.

    Thank you.
Back to Top