2012-01-12 78 views
0

我正在使用Radeditor。我需要從剪貼板獲取內容並設置爲編輯內容。如何使用javascript將內容設置爲radeditor

我得到的內容。但我把內容設置爲編輯頁面,它顯示爲空。

我使用下面的代碼。

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

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

所以我嘗試綁定服務器端的內容。所以我使用pagemethods.i調用了服務器端函數,在腳本管理器中設置了EnablePageMethods =「true」。

但它顯示頁面方法未定義。

我的第一要務是用java腳本設置內容。

如何做到這一點?

感謝,

普加

回答

3

試試下面的代碼:

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

問候,

Dhaval舒克拉

1

您可以使用兩種不同的方法:

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

相關問題