retrieve data from editor

Last post 01-09-2006, 1:47 PM by Adam. 3 replies.
Sort Posts: Previous Next
  •  12-16-2005, 9:58 AM 13959

    retrieve data from editor

    Hi
    My integration is like this.
    1)the editor is deployed as an asp.net application
    2)In ourmain asp page, we have a iframe that links to the asp.net editor page
    3)our main asp page has quite a few other data fields and when a user click "save" button in the main asp page, it should save the editor data and the data in ohter fields. That is, we don't desire to save the editor data by clicking the save button in the editor to save the editor separately. To solve this issue, I tried to add a javascript in the main asp page. The script first find the iframe document and then using the iframe document to retrieve the editor data in the textarea called called "Editor1". This hacking works partially. I always got the original data although I added some new stuff the editor. Any solutions to this issue will be appreciated.

    Mark
     
  •  12-16-2005, 3:31 PM 13969 in reply to 13959

    Re: retrieve data from editor

    Mark,
     
    First it's possible to retrieve the data from the editor using the client side script.

    Here is a demo:

    http://cutesoft.net/example/JavaScript-API.aspx

    Code is as followings:

    function getHTML()
    {
        // get the cute editor instance
        var editor1 = document.getElementById('<%=Editor1.ClientID%>');
        
        // Get the editor HTML
        document.getElementById("myTextArea").value = editor1.getHTML();
    }  


    Here is another demo which show you use the CuteEditor in ASP, PHP and JSP applications.

    http://cutesoft.net/example/dad.html

    Hope it helps.

    Let me know if you have any further questions.




       
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-09-2006, 1:23 PM 14533 in reply to 13969

    Re: retrieve data from editor

    Adam, can you make available the aspx code for the "dad" example (i.e. kid.aspx)?
     
    Darryl
  •  01-09-2006, 1:47 PM 14535 in reply to 14533

    Re: retrieve data from editor

    Darryl,
     
     
    Here it is:
     
     
    Dad.htm
     
    <HTML>
    <HEAD>
    <SCRIPT>
    function popupCuteEditor(v_form, v_field)
    {
     var newWin, v_pagestring;
     w = 770;
     h = 500;
     LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
     TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
     settings = 'height='+h+',width='+w+',top='+TopPosition+',left='; 
     v_pagestring = "kid.aspx?form=" + v_form + "&field=" + v_field;
     newWin =window.open(v_pagestring,"HTMLEdit",settings + LeftPosition+'resizable=yes')
    }
    </SCRIPT>
    <TITLE>Parent Page</TITLE>
    </HEAD>
    <body>
     <p></p>
     <FORM name="f1" method=POST target='kid'>
      <textarea name="t1" cols="100" rows="15">Text Area 1 Text</textarea><br/>
      <input type="button" value="Edit In CuteEditor" name="B1"  onclick="popupCuteEditor('f1','t1')">
     </FORM>
    </BODY>
    </HTML>


    Kid.aspx
     
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <HTML>
    <HEAD>
    <script>
    // querystring
    // Call function by x = querystring("variable") returns variable=x
    function querystring(key)
    {
     var value = null;
     for (var i=0;i<querystring.keys.length;i++)
     {
      if (querystring.keysIdea [I]==key)
      {
       value = querystring.valuesIdea [I];
       break;
      }
     }
     return value;
    }
    querystring.keys = new Array();
    querystring.values = new Array();
    function querystring_parse()
    {
     var query = window.location.search.substring(1);
     var pairs = query.split("&");
     for (var i=0;i<pairs.length;i++)
     {
      var pos = pairsIdea [I].indexOf('=');
      if (pos >= 0)
      {
       var argname = pairsIdea [I].substring(0,pos);
       var value = pairsIdea [I].substring(pos+1);
       querystring.keys[querystring.keys.length] = argname;
       querystring.values[querystring.values.length] = value;
      }
     }
    }
     
    querystring_parse();
    // Set the parent windows form and field to a variable
    var v_parentform, v_field, v_form;
    v_field = querystring("field");
    v_form = querystring("form");
    var v_parent = "window.opener.";
    v_parentform = eval(v_parent + v_form);
     
    function tellDad()
    {
     // get the cute editor instance
     var editor1 = document.getElementById('<%=Editor1.ClientID%>');
        
     // Get the editor HTML
     v_parentform.elements[v_field].value = editor1.getHTML();
    }
    function getparentdata()

     // get the cute editor instance
     var editor1 = document.getElementById('<%=Editor1.ClientID%>');
     
     // Set the editor
     editor1.setHTML(v_parentform.elements[v_field].value);
     
    }
    </SCRIPT>
    <TITLE>Kid Child Window</TITLE>
    </HEAD>

    <body bottomMargin="0" topMargin="0" marginwidth="0" marginheight="0" onload="setTimeout(getparentdata,1000);" bgcolor="#efefef">
     <form runat="server">
     <CE:Editor  EditorWysiwygModeCss="style.css" id="Editor1" runat="server" ></CE:Editor>
     <br/>
     <INPUT type="button" value='Get Parent data' onClick="getparentdata();" >
     <INPUT type="button" value='Set Parent value' onClick="tellDad(); window.close();" >
     <br/>
    </form>
    </BODY>
    </HTML>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML