user123 user123 - 1 month ago 9
HTML Question

How to remove html code at the time of page loads ck editor loading the text in asp.net

In my wed application, I have one page it contains ck editor when i load that page ck editor showing some fraction of seconds HTML code after it will display text in ck editor. I need to stop that showing fraction of seconds HTML code how can i do this can anyone tell me.

My code is:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
GetTemplate();
}
}
Public void GetTemplate()
{
ShowTemplate();
}
Public void ShowTemplate()
{
//showTemplate code
CKEditor1.Text = html;
}


Thank you.

Answer

CKEditorYou can use a simple javascript trick to "hide" the CKEditor until it has been initialized.

<div style="height: 400px; width: 600px;">
    <div style="display: none" id="CKPlaceHolder">
        <asp:TextBox ID="CKEditorTextBox" runat="server" TextMode="MultiLine"></asp:TextBox>
    </div>
</div>

I use 2 <div> elements. One to actually hide the editor and the first one as a placeholder to prevent the jumping of the content once the editor will be shown.

And then somewhere in JavaScript:

setTimeout(function () { document.getElementById('CKPlaceHolder').style.display = "block"; }, 500);