Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure which version you are using, but let's suppose that it's 3.x. I was playing around with the control and didn't find any possible way of doing this from code behind. However, I managed to make it work like this:</p> <pre><code>Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "fckInitialization", @" window.onload = function () { var oEditor = CKEDITOR.instances['" + txtPost.ClientID + @"']; oEditor.insertHtml('&lt;strong&gt;This is a bold text.&lt;/strong&gt;'); }; ", true); </code></pre> <p>I tried it in IE 8 and the last version of Mozilla (I think it was 9) and it worked. I also tried the same thing, but instead of <strong>window.onload</strong> I used the jQuery <strong>$(document).ready()</strong> and it worked only in IE. The reason is that you have to wait for everything to load in order to use the functions from the CKEditor API. I played with Firebug and the <strong>insertHTML</strong> worked. If you are using 2.x, you can see somewhere in Google the same approach, but with a different API. I just can't find the link right now.</p> <p>Another problem will be here, as you may figure out, that if you want to initialize a long text, you will have to write everything in a script, which is not really nice.</p> <p>Maybe a possible solution for you will be to convert the HTML to BBCode first and then just set the <strong>Text</strong> property. This, of course, depends on the way you use the control, because BBCode does not contain all possible tags, but you can always modify the bbcode plugin of CKEditor to meet your needs. And I tested it and it works.</p> <p>PS. Probably you can do it with the JavaScript method and an AJAX call.</p> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload