how to set the content to radeditor using javascript

社会主义新天地 提交于 2019-12-08 12:04:33

问题


I am using Radeditor. i need to get the content from clip board and set to editor conten.

i am get the content. but i set the content to editor page, it shows empty.

i am using the following code.

 var content = window.clipboardData.getData("Text");

   if (content != null) {
      editor.set_html = content;

so i try to bind the content in server side. so i called the server side function using pagemethods.i set EnablePageMethods ="true" in script manager.

but it shows page methods is undefined.

my first priority is set the content using java script.

How to do this?

Thanks,

Pooja


回答1:


Try Below Code:

var newValue = "control alt delete";
    $find("<%=RadEditor1.ClientID%>").set_html(newValue);

Regards,

Dhaval Shukla




回答2:


you can use 2 different methods:

    var editor = $find("<%=RadEditor1.ClientID%>");
    var stringVal = window.clipboardData.getData("Text"); 
    if(stringVal != null){
         editor.set_html(stringVal); //replaces the content of the editor with stringVal
         editor.pasteHtml(stringVal); //pastes your string val at the cursor (Defaults to end of the content window if no cursor found)
    }

you can get the full API documentation here: http://www.telerik.com/help/aspnet-ajax/editor-pastehtml.html




回答3:


http://www.telerik.com/community/forums/aspnet-ajax/editor/fill-content-through-javascript-in-telerik-editor.aspx

RadEditor is a composite control and to get a reference to its client object you should use:

var editor = $find("<%=RadEditor1.ClientID%>");
var content = window.clipboardData.getData("Text");
if (content != null) {
  editor.set_html = content;


来源:https://stackoverflow.com/questions/8830484/how-to-set-the-content-to-radeditor-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!