c# - How to save data from summernote into SQL DB -
how guys?
i have asp.net webform adding news in news content use summernote http://summernote.org/ super simple wysiwyg editor. wysiwyg editor 1 please me save data editor
this code
<div class="form-body"> <div class="form-group last"> <label class="control-label col-md-2">news content</label> <div class="col-md-10"> <div name="summernote" id="summernote_1"> </div> <asp:label runat="server" text="label" id="news_con" ></asp:label> </div> </div> </div> i can't text value summernote code news_con.text = request.form["summernote_1"];
have considered using <textarea> handle opposed <div>? bit easier use respect storing values (as designed so) :
<textarea id="txttest" runat="server"></textarea> one of ways might handle register event using summernote's available api set html content <textarea> element whenever focus lost (e.g. onblur) :
<script> $(function () { // set summernote instance $("#txttest").summernote(); // when summernote instance loses focus, update content of <textarea> $("#txttest").on('summernote.blur', function () { $('#txttest').html($('#txttest').summernote('code')); }); }); </script> since going storing html content within element, you'll want ensure .net doesn't think trying exploit it. can either explicitly setting page ignore process updating validaterequest property of page :
<%@ page ... validaterequest = "false" %> or try escaping content being set :
$('#txttest').html(escape($('#txttest').summernote('code')));
Comments
Post a Comment