views:

181

answers:

1

Hi,

I'm using the AJAX Control toolkit HTML editor and have what I hope is a simple question. As the question title says - how do you get/set the content of the HTML editor via javascript ?

I have no problems accessing the server side content property - but how to do it client side ??!?

Any help gratefully received !

Thanks,

Tim.

A: 

The Html Editor is one of the unique Ajax Control Toolkit controls, becuase it does not inherit AjaxControlToolkit.ExtenderControlBase (server side) nor inherit AjaxControlToolkit.BehaviorBase (client side).

So you can't use $find javascript method to get access to the behavior instance on the client, It inherits AjaxControlToolkit.ScriptControlBase (server side) and Sys.UI.Control (client side).

To get access to control instance on the client, you use the control property on the DOM element it self as follows:

<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>
MK
Perfect - thanks !
Polecat Harris

related questions