Tuesday, March 1, 2011

How can I enable live preview for FCKeditor in an ASP.Net site?

Over in this question, Scott writes that it is possible to get the current HTML for what's written in the FCKeditor by using FCKeditorAPI.__Instances['instanceNameHere'].GetHTML();

Could someone provide step-by-step instructions on how to accomplish this in an ASP.NET page? All I currently have so far in the .aspx file is this:

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Page Title="" Language="C#" ... %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Create a new piece</h2>
<form id="form1" runat="server">

<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server">
</FCKeditorV2:FCKeditor>

<input id="Submit1" type="submit" value="Submit" runat="server" />
</form>
</asp:Content>
From stackoverflow
  • In javascript

    Well you can do this here:

    <script type="text/javascript">
        var oEditor = FCKeditorAPI.GetInstance(’IDFromFCKEditor’);
        oEditor.Events.AttachEvent( 'OnSelectionChange', function() {
            document.getElementById("PreviewDiv").innerHTML = oEditor.GetHTML(true);
        }) ;
    </script>
    

    Source http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API

    Jedidja : In case anyone needs this later, you will want to wrap the code José provides inside the following: function FCKeditor_OnComplete(editorInstance)
    José Leal : Oh yes, sorry to forget..

0 comments:

Post a Comment