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

[Solved] radeditor

3 Answers 121 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ayesha
Top achievements
Rank 1
Ayesha asked on 04 Aug 2009, 02:47 AM

 

Hi,

I  need the selected text of a dropdown control's value to be pasted in my radeditor

how is it possible. can u help me with the code.
So, based on the selected value from a dropdownlist, that selcted value gets pasted in my radeditor depending on my cursor position.
I'm using the pastehtml method.

Give me some egs of how to insert the raddropdownlist's selected value which is a separate ctrl and take that text and paste it  in the radeditor depending on it's caret/cursor position.
pls do help me with code

Thanks,
ZR

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Aug 2009, 10:25 AM

Hi Zaheka ,

I found one help document "Inserting Text from a Text Control at the Cursor Position", try the same logic to insert the raddropdownlist's selected value in the radeditor.
here is the contents:

The example below demonstrates how to insert text at the cursor position in RadEditor when a button is clicked:

#  Add a textbox to your page:  
 
ASPX/ASCX   <telerik:radeditor runat="server" ID="RadEditor1"></telerik:radeditor> 
<asp:textbox id="TextBox1" runat="server" height="97px"></asp:textbox> 
 
 
# Add a button to execute the paste command:  
 
ASPX/ASCX    
 
<input id="Insert" type="button" value="<--Insert" onclick="PasteTextInEditor(Form1.TextBox1.value);">  
 
 
# Include the PasteTextInEditor method in your ascx/aspx file. Use the pasteHtml method to paste the content from the textbox:  
JaveScript   
 
<script type="text/javascript">  
function PasteTextInEditor(text)  
{  
   var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object  
   editor.pasteHtml(text); //PasteHtml is a method from the editor client side API  
}  
</script>   
 


-shinu..
0
Ayesha
Top achievements
Rank 1
answered on 05 Aug 2009, 03:24 AM
Hi Shinu ,

Thanks for ur reply .

But i tried like the sample u provided but it's giving me an error while running:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

 

<

 

head id="Head1" runat="server">

 

 

 

 

 

<title>Untitled Page</title>

 

<

 

script type="text/javascript" language="javascript">

 

function

 

PasteTextInEditor(text)

 

{

 

var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object

 

 

 

 

editor.pasteHtml(text);

//PasteHtml is a method from the editor client side API

 

 

 

 

}

 

 

</

 

script>

 

 

 

</

 

head>

 

 

<

 

body>

 

 

 

 

 

 

<form id="form1" runat="server">

 

 

 

 

 

<asp:ScriptManager ID="ScriptManager1" runat="server">

 

 

 

 

 

</asp:ScriptManager>

 

 

 

 

 

<div>

 

 

 

 

 

 

 

<

 

telerik:RadComboBox ID="radcombobox2" runat="server"></telerik:RadComboBox>

 

 

 

 

 

 

 

<input id="Insert" type="button" value="<--Insert" onclick="PasteTextInEditor(form1.radcombobox2.value);" />

 

 

 

 

 

<telerik:RadEditor ID="RadEditor1" runat="server">

 

 

 

 

 

</telerik:RadEditor>

 

 

</div>

 

 

 

 

 

</form>

Pls do help me.

Thanks,
ZR

 

0
Georgi Tunev
Telerik team
answered on 05 Aug 2009, 05:08 AM
Hi Zaheka,

You should have your JavaScript code wrapped in a RadCodeBlock in order to avoid this error. More information on the subject is available here.

Greetings,
Georgi Tunev
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
Ayesha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ayesha
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or