Ive a radeditor in my form. My scenario is I need to insert text in the position exactly where my caret is(or cursor is)??
Eg:: if my content in radeditor is : hi, how are you?? and i ned to insert 'John' after 'how' ??
how do i do this ???
so, once inserted, it should be hi john, how are you?? how do you insert text in radeditor using the caret position.
Pls help me with code samples.
Also, when i use radeditor and use the toolbr in radedito, it gives me an error telling need to configure in web.config? how do i resolve this???
Thanks,
ZR
5 Answers, 1 is accepted
You can use the pasteHtml method of RadEditor to paste content to cursor position.
You have not send the exact error message and provided sufficient information about the toolbar button problem. Do you get this error when trying to open some of the RadEditor dialogs? If this is your scenario then see the following KB article: Error: Web.config registration missing! The Telerik dialogs require a HttpHandler registration in the web.config file.
Kind 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.
As per ur suggestion,
I created a javascript fn with the below code
function InsertSpan()
{
var editor = $find("<%=RadEditor1.ClientID%>");
editor.pasteHtml('<span style="width:100px;border: 1px solid red;background-color: blue;color: white;">sample content</span>');
}
But here it has a fixed text like 'sample content ' always.
But 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.
pls do help me with code
Thanks,
ZR
The pasteHtml method expects a string. How this string is constructed and what it contains is not related to RadEditor functionality per ce.
If you use a dropdown, you likely need to get the [current selected] value from the dropdown and insert it, e.g. something similar to this:
editor.pasteHtml('<span>' + control.get_value() + "</span>');
The following demo on custom tools in fact provides such use of the pasteHtml method:
http://demos.telerik.com/aspnet-ajax/editor/examples/customtools/defaultcs.aspx
Best regards,
Tervel
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.
I've a radeditor and a radcombobox in my usercontrol (.ascx).
My scenario is I need to select some value from radcombobox and insert that value in the RADeditor. I got this working by the below approach.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function getSelected()
{
var obTagCombo = $find('<%=m_radTagCombo.ClientID %>');
var value = obTagCombo.get_value();
var text = obTagCombo.get_text();
var editor = $find("<%=m_radEmailEditor.ClientID%>"); //get a reference to RadEditor client object
editor.pasteHtml(text);
}
</script>
</telerik:RadCodeBlock>
and i have a button <input type="button" value="Insert Tag" onclick="getSelected();" />
when this button is clicked it inserts the text from combobox and puts it in radeditor.
Note: m_radTagCombo is my name of radcombobox and m_radEmailEditor is my radeditor name.
But my problem is : I've my curor at the radeditor a a particular position. When I select a value from radcombobox, the cursor
position defaults to the begining of the line(first place).
Pls tell me how do I preserve the cursor position without going back to first position when i select value from a combobox.
pls do help me with code.
When you click on the combobox and expand it then the focus in the editor is lost and for that reason the pasteHtml function pastes the content at the beginning of the content area.
To fix the problem you should set unselectable="on" attribute to all combobox elements. Here is an example how to achieve this:
| <script type="text/javascript"> |
| function OnClientLoad(combobox, args) |
| { |
| makeUnselectable(combobox.get_element()); |
| } |
| //Make all combobox items unselectable to prevent selection in editor being lost |
| function makeUnselectable(element) |
| { |
| var nodes = element.getElementsByTagName('*'); |
| for (var index = 0; index < nodes.length; index++) |
| { |
| var elem = nodes[index]; |
| elem.setAttribute('unselectable','on'); |
| } |
| } |
| </script> |
| <telerik:radeditor runat="server" ID="m_radEmailEditor"> |
| <ImageManager ViewPaths="~/" UploadPaths="~/" DeletePaths="~/" /> |
| </telerik:radeditor> |
| <telerik:RadComboBox OnClientLoad="OnClientLoad" ID="m_radTagCombo" runat="server"> |
| <Items> |
| <telerik:RadComboBoxItem Text="Item1" Value="Item 1" /> |
| <telerik:RadComboBoxItem Text="Item2" Value="Item 2" /> |
| <telerik:RadComboBoxItem Text="Item3" Value="Item 3" /> |
| </Items> |
| </telerik:RadComboBox> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function getSelected() |
| { |
| var obTagCombo = $find('<%=m_radTagCombo.ClientID %>'); |
| var value = obTagCombo.get_value(); |
| var text = obTagCombo.get_text(); |
| var editor = $find("<%=m_radEmailEditor.ClientID%>"); //get a reference to RadEditor client object |
| editor.pasteHtml(text); |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <input type="button" value="Insert Tag" onclick="getSelected();" /> |
I have also attached my test aspx page.
All the best,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
