asp.net - WYSIWYG Text Editor SummerNote Entered data is not persisting -


a picture of problem

above picture of edit page. issue have editor (summernote) not persist it's data when save

**i have however, narrowed down problem. **

  • fields on form persist data in value field on html elements
  • summernote not store text i've written editor in value element
  • if use default editor , put value in (which stored in value element), use summernote, value in value field there, not displayed.
  • editing value field in inspector cause value persisted on save.

the line containing value field:

<input class="form-control text-box single-line" id="content_content" name="content.content" type="text" value="i text not shown persisted!" style="display: none;">

the note-editing-area div:

<div class="note-editing-area"><div class="note-handle"><div class="note-control-selection" style="display: none;"><div class="note-control-selection-bg"></div><div class="note-control-holder note-control-nw"></div><div class="note-control-holder note-control-ne"></div><div class="note-control-holder note-control-sw"></div><div class="note-control-sizing note-control-se"></div><div class="note-control-selection-info"></div></div></div><textarea class="note-codable"></textarea><div class="note-editable panel-body" contenteditable="true" style="height: 320px;"><h1>help!</h1><p>what type here not persisted when click <b>save </b>button.</p></div></div>

my question therefore this:

how can either

  1. have html between ::before , ::after of summernote editor (the value user types control) put value tag aswell persisted
  2. do else make work.




additional information:

here model:

article.cs:

public class article {     #region constructors      public article(string title, string subtitle = "")     {         initializecollections();         title = title;         subtitle = subtitle;     }     public article(string title, article parentarticle, string subtitle = "")     {         initializecollections();         title = title;         subtitle = subtitle;         parentarticles.add(parentarticle);     }      public article()     {         initializecollections();     }      void initializecollections()     {         parentarticles = new list<article>();         childarticles = new list<article>();     }      #endregion      [key]     public int articleid { get; set; }     public virtual articlecontent content { get; set; }      [stringlength(guiconstants.maxcharactersinmenuitemtext)]     public string title { get; set; }     [stringlength(100)]     public string subtitle { get; set; }     public int? sequence { get; set; }     public bool published { get; set; }     public datetime? publisheddate { get; set; }     public virtual icollection<article> parentarticles { get; set; }     public virtual icollection<article> childarticles { get; set; }     public string notes { get; set; } 

article content (it's content's content property has wysiwyg editor, if use wysiwyg property dirrectly on article model (like title) same issue.

    public class articlecontent {     [key, foreignkey("article")]     public int articleid { get; set; }     public virtual article article { get; set; }     [allowhtml]     public string content { get; set; } } 

}

controller:

// get: articles/edit/5     public actionresult edit(int? id)     {         if (id == null)         {             return new httpstatuscoderesult(httpstatuscode.badrequest);         }          var article = db.article.include(a => a.content).singleordefault(a => a.articleid == id);          if (article == null)         {             return httpnotfound();         }          return view(article);     }      // post: articles/edit/5     // protect overposting attacks, please enable specific properties want bind to,      // more details see http://go.microsoft.com/fwlink/?linkid=317598.     [validateinput(false)]     [httppost, actionname("edit")]     public actionresult editpost(int? id)     {         if (id == null)         {             return new httpstatuscoderesult(httpstatuscode.badrequest);         }          var articletoupdate = db.article.include(a => a.content).singleordefault(a => a.articleid == id);          if (tryupdatemodel(articletoupdate, "",            new string[] { "title", "subtitle", "sequence", "content" }))         {             try             {                 db.savechanges();                  return redirecttoaction("index");             }             catch (retrylimitexceededexception /* dex */)             {                 //log error (uncomment dex variable name , add line here write log.                 modelstate.addmodelerror("", "unable save changes. try again, , if problem persists, see system administrator.");             }         }         return view(articletoupdate);     } 

view:

    **@model catalyst.models.article  @{     viewbag.title = "edit article"; }  @section styles{     @styles.render("~/content/summernote") }  @using (html.beginform()) {     @html.antiforgerytoken()      <div class="form-horizontal">         @html.validationsummary(true, "", new { @class = "text-danger" })         @html.hiddenfor(model => model.articleid)          <div class="form-group">             @html.labelfor(model => model.title, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.title, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.title, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             @html.labelfor(model => model.subtitle, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.subtitle, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.subtitle, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             @html.labelfor(model => model.sequence, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.sequence, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.sequence, "", new { @class = "text-danger" })             </div>         </div>         <div class="form-group">             @html.labelfor(model => model.content.content, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.content.content, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.content.content, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             <div class="col-md-offset-2 col-md-10">                 <input type="submit" value="save" class="btn btn-default" />             </div>         </div>     </div> }  <div>     @html.actionlink("back list", "index", "articles", new { @class = "btn btn-default" }) </div>  @section scripts {    @scripts.render("~/bundles/summernote", "~/bundles/summernotearticlecontenteditor") }** 

the javascript turning content textbox summernote

    (function ($) {       function homeindex() {           var $this = this;            function initialize() {               $('#content_content').summernote({                 focus: true,                   height: 320,                     codemirror: {                        theme: 'united'                   }               });           }            $this.init = function () {               initialize();           }       }     $(function () {           var self = new homeindex();           self.init();       }) }(jquery)) 

i followed guide: http://www.c-sharpcorner.com/uploadfile/3d39b4/bootstrap-wysiwyg-editor-in-asp-net-mvc/


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -