【问题标题】:how to set the content to radeditor using javascript如何使用javascript将内容设置为radeditor
【发布时间】:2012-02-08 11:17:56
【问题描述】:

我正在使用 Radeditor。我需要从剪贴板中获取内容并设置为编辑器内容。

我得到了内容。但我将内容设置为编辑器页面,它显示为空。

我正在使用以下代码。

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

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

所以我尝试在服务器端绑定内容。所以我使用 pagemethods 调用了服务器端函数。我在脚本管理器中设置了 EnablePageMethods ="true"。

但它显示页面方法未定义。

我的首要任务是使用 java 脚本设置内容。

如何做到这一点?

谢谢,

普佳

【问题讨论】:

    标签: javascript asp.net telerik


    【解决方案1】:

    您可以使用 2 种不同的方法:

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

    您可以在此处获取完整的 API 文档:http://www.telerik.com/help/aspnet-ajax/editor-pastehtml.html

    【讨论】:

      【解决方案2】:

      试试下面的代码:

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

      问候,

      达瓦尔舒克拉

      【讨论】:

        【解决方案3】:

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

        RadEditor 是一个复合控件,要获得对其客户端对象的引用,您应该使用:

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

        【讨论】:

          猜你喜欢
          • 2023-03-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-05-06
          • 2012-02-24
          • 1970-01-01
          • 2020-10-21
          • 2011-06-14
          相关资源
          最近更新 更多