Log in or register to post comments
Last post
Populate from Database with ASP.NET Version
How do I populate an editor instance with content from a database, originally created with CKEditor (ie, in html form). I want text to appear in editor pane without the markup, but rendered as originally input...
Re: Populate from Database with ASP.NET Version
You can search the forum to see how others have done it, like here.
Re: Populate from Database with ASP.NET Version
I'm really looking for the syntax - how to get and set the HTML content - do I have to HTML decode it when populating from the DB?
Re: Populate from Database with ASP.NET Version
This is what works for me with ASP.NET
In head ...
    <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>

In body ...
         <div>
            <textarea id="editor1" name="editor1">
               <%= WriteEditor() %>
            </textarea>
         </div>
         <script type="text/javascript">
            var editor = CKEDITOR.replace( 'editor1' );
         </script>

In aspx.cs ...
in the Submit handling
         string ckInput = Request.Form["editor1"]; // save this to the db

For populating screen from the saved content
      protected string WriteEditor() {
         return htmlContent; // the html saved previously or blank if new
      }


Hope this helps
Dave
Re: Populate from Database with ASP.NET Version

You can convert html control to server control by adding runat="server" in html side ,

such as

<textarea  rows="5" cols="5" id="editor1"  runat="server"></textarea>

then in the code behind  you can get or set the value using  editor1.Value

such as

Label1.Text = editor1.Value.ToString();     // to get the value of the editor

editor1.Value = "Hello CkEditor!";     // to set the value of the editor