How do you get / install content via javascript using the AJAX Control Toolkit HTML editor?

I am using the AJAX Control toolkit HTML editor and hope this is a simple question. As the title of the question says - how do you get / set the contents of an HTML editor through javascript?

I have no problem accessing the contents of the content on the server side, but how to do it on the client side?

Any help gratefully received!

+3
source share
3 answers

Html Ajax Control Toolkit, AjaxControlToolkit.ExtenderControlBase ( ) AjaxControlToolkit.BehaviorBase ( ).

, $find javascript , AjaxControlToolkit.ScriptControlBase ( ) Sys.UI.Control ( ).

, DOM, :

<script type="text/javascript">
//considering the editor is loaded.
var editorControl = $get("<%=editor.ClientID%>").control;

//1. For setting content:
editorContorl.set_content("Sample Content");

//2. For getting content:
var content = editorContorl.get_content();    
</script>
+8
$(function(){
    $find("editor").set_content("jQuery set content");
    alert($find("editor").get_content());
});
0

. html . / //.

<script type="text/javascript">
    var varcont = '<%=txtInstructions.ClientID %>' + '_ctl02_ctl00';
    //Get Content
    var content = document.getElementById(varcont).contentWindow.document.body.innerHTML; 

    //Set Content
    document.getElementById(varcont).contentWindow.document.body.innerHTML='<b>I rock</b>'
</script>
0

Source: https://habr.com/ru/post/1756726/


All Articles