如何使用AJAX Control Toolkit HTML编辑器通过javascript获取/设置内容?

问题描述:

我正在使用AJAX控制工具包HTML编辑器,希望有一个简单的问题。正如问题标题所述-您如何通过javascript获取/设置HTML编辑器的内容?

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 !

Html编辑器是唯一的Ajax Control Toolkit控件之一,因为它不继承 AjaxControlToolkit.ExtenderControlBase (服务器端),也不继承 AjaxControlToolkit.BehaviorBase (客户端)。

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).

所以您不能使用 $ find javascript方法访问客户端上的行为实例,它继承 AjaxControlToolkit.ScriptControlBase (服务器端)和 Sys.UI.Control (客户端)。

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).

要访问客户端上的控件实例,请按以下方式使用DOM元素本身的控件属性:

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>