RadTextBox.get_caretPosition() returns meaningless value

3 posts, 0 answers
  1. Darwin
    Darwin avatar
    9 posts
    Member since:
    Jan 2013

    Posted 18 Jan 2013 Link to this post

    I need to know where the caret is in a RadTextBox while an action is occurring in RadComboBox.  For example, somebody selects an item in the combobox, an item's value is to be inserted into the text in the RadTextBox at the position of the caret. As I try to determine the location of the caret by calling "get_caretPosition" on the RadTextBoxm I always get the same value -7341.

    This is an incomplete function but enough to determine that I'm not getting the value I expected:

                function CannedNoteSelected(sender, eventArgs) {
                    var selectedValue = eventArgs.get_item().get_value();
                    var pos = $find('<%= NoteToClientTxt.ClientID %>').get_caretPosition();
    ... do stuff here to insert merge new text into existing text but pos always contains -7310 no matter where the caret really is ...
                    $find('<%= NoteToClientTxt.ClientID %>').set_value(selectedValue);
                }
     What am I doing wrong?
  2. Darwin
    Darwin avatar
    9 posts
    Member since:
    Jan 2013

    Posted 21 Jan 2013 Link to this post

    To answer my own question, as soon as the user clicks on the combobox, the focus changes from the textbox to the combobox and the caret is no longer in the textbox hence there is no caret position to return.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Jan 2013 Link to this post

    Hi Darwin,

    Thank you for updating the thread and share your answer. Do let us know if you have additional questions or further assistance is needed.


    Kind regards,
    Maria Ilieva
    the Telerik team
    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 their blog feed now.
Back to Top