RadEditor Current Cursor Position

4 posts, 0 answers
  1. Dinakaran
    Dinakaran avatar
    9 posts
    Member since:
    Aug 2013

    Posted 17 Jan 2014 Link to this post

    Hi,
          I need to find the RadEditor cursor position to place some text from another screen,i have tried to find the cursor position at the end of the each line but i can't able to find the cursor position between the words,please refer the images to analyse.

    Thanks & Regards,
          Dinakaran
  2. Nikolay
    Admin
    Nikolay avatar
    64 posts

    Posted 21 Jan 2014 Link to this post

    Hi Dinakaran,

    You can use editor.pasteHtml function to insert any content to the cursor position.

    Another way is to get the RadEditor range object - editor.getSelection.getRange(true). Then using range.pasteHTML function for IE7 and IE8 and range.insertNode for other browsers to insert content.

    Regards,
    Nikolay
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marco
    Marco avatar
    2 posts
    Member since:
    Jul 2012

    Posted 19 Aug 2014 Link to this post

    Hi,
    I'm using pasteHtml to add some text and it's correctly added on cursor position on Chrome and FF but non on ie9 or ie10. On both IE test is put at the start of the text area. It's known issue ?

    Thanks,
    Marco
  5. Nikolay
    Admin
    Nikolay avatar
    64 posts

    Posted 21 Aug 2014 Link to this post

    Hi,

    Internet Explorer does not keep the selection when the RadEditor's contentArea loses its focus. To workaround this, you can get and store the RadEditor's range. You can get it on OnClientSelectionChange event and restore it before paste.

    Here is an example:
    <telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad" OnClientSelectionChange="OnClientSelectionChange">
        <Content>
            <p>Some test content</p>
        </Content>
    </telerik:RadEditor>
     
    <telerik:RadButton ID="RadButton_InsertHtml" runat="server" Text="Insert HTML" OnClientClicked="Button_OnClick" AutoPostBack="false" />
     
    <script>
        var editor, range;
        function OnClientLoad(sender, args) {
            editor = sender;
        }
     
        function OnClientSelectionChange(sender, args) {
            range = editor.getSelection().getRange(true);
        }
     
        function Button_OnClick() {
            if (range) {
                editor.getSelection().selectRange(range);
            }
            editor.pasteHtml("Inserted Text");
        }
    </script>


    Regards,
    Nikolay
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top