Ajax Functionality

Last post 02-22-2011, 11:12 AM by ASPMan. 4 replies.
Sort Posts: Previous Next
  •  02-22-2011, 8:53 AM 66353

    Ajax Functionality

    I am using the cuteeditor and attempting to do some of the functionality via Ajax, such as loading and retrieving values from the editor. Basically what I am doing is taking the value of a div and then placing it inside of the editor, once I am done editing the information I put the value back into the div again. This worked fine using the javascript API as such:
     

    var editor1 = document.getElementById('<%=Editor1.ClientID%>');

    editor1.setHTML("this is a test");

    The problem is that you cannot use the syntext <%=Editor1.ClientID%> with the ajax control toolkit without getting a block code error. Is there a different approach to handling this issue? The standard document.getElementById does not work with the editor.
  •  02-22-2011, 10:26 AM 66357 in reply to 66353

    Re: Ajax Functionality

    Dear ASPMan,
     
    You can replace <%=Editor1.ClientID%> with a string, please refer to the following snippet:
     
    <script language="JavaScript" type="text/javascript" >
           function getHTML() {
               // get the cute editor instance
               var editor1 = document.getElementById('CE_Editor1_ID');

               // Get the editor HTML
               document.getElementById("myTextArea").value = editor1.getHTML();
           }

           function setHTML() {
               // get the cute editor instance
               var editor1 = document.getElementById('CE_Editor1_ID');

               // Set the editor
               editor1.setHTML(document.getElementById("myTextArea").value);
           }
    Thank you for asking
     
  •  02-22-2011, 11:07 AM 66360 in reply to 66357

    Re: Ajax Functionality

    Writing the set function the way you have gives you a javascript error:
     
    "Object does not support this method of property"
  •  02-22-2011, 11:11 AM 66362 in reply to 66360

    Re: Ajax Functionality

    Dear ASPMan,
     
    document.getElementById('CE_Editor1_ID');
     
    You only need refer to this line, use it in your own code.
     
    The full code can be found in "Framework 2.0\cs\JavaScript-API.aspx", you can find this file in download package.
     
    Thank you for asking
  •  02-22-2011, 11:12 AM 66363 in reply to 66360

    Re: Ajax Functionality

    I think I got it now, its more about when the editor is actually displayed then the API functionality. My page is set up to only display the editor as needed, and I needed to make it display prior to attempt to set the html apparently.
     
    Thanks for the help
View as RSS news feed in XML