This is a migrated thread and some comments may be shown as answers.

Using 'pasteHtml' to capture value of and external input button

1 Answer 37 Views
Editor
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Jul 2009, 02:21 PM

Greetings,

Sorry about the question title.  It should read:

"Using 'pasteHtml' to capture the value of an external input button"

I found the following code here on site with the associated title:

The following example will show you how to paste content into the editor's content area from an external input button:
----------------------------------------------------------------------------------------------------------------------------- 
<telerik:radeditor runat="server" ID="RadEditor1"></telerik:radeditor>
<input type="button" value="Paste Content" onclick="InsertSpan();return false;" />

<script type="text/javascript">
function InsertSpan()
{                 
  var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to the editor
  editor.pasteHtml('<span style="width:100px;border: 1px solid red;background-color: blue;color: white;">sample content</span>');
}
</script>    
-----------------------------------------------------------------------------------------------------------------------------

Can anybody explain to me how this does _anything_ with a value outside the RadEditor.  Seems to me there is a very necessary piece left out of the example.  For instance, when using  'OnClientCommandExecuting(editor, args)' to do this kind of thing 'within' the editor, the args parameter is used to produce the value of 'val':

var val = args.get_value();

editor.pasteHtml("<div style='width:100px;background-color:#fafafa;border:1px dashed #aaaaaa;'>" + val + "</div>");

As we can see, the code provided for the external input doesn't come close to addressing how to handle the outside value.

Am I missing something here??

Thanks!

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 20 Jul 2009, 01:37 PM
Hi John,

The OnClientCommandExecuting event is fired only when internal RadEditor's command is executed. For example this event is executed when a built-in or custom toolbar button is pressed by the user. This event is not executed when an external button on the page outside of the editor is pressed.

It is up to the developer to supply the desired content to the pasteHtml method when pasting content through an external button.  You can see that in the example the pasteHtml method just pastes content defined by the developer. You can use a hiddenfield to pass the content from the server and after that set the value of the hiddenfield as a parameter of the pasteHtml function.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
John
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or