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

RadTextBox.get_caretPosition() returns meaningless value

2 Answers 93 Views
Input
This is a migrated thread and some comments may be shown as answers.
Darwin
Top achievements
Rank 1
Darwin asked on 18 Jan 2013, 10:45 PM
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 Answers, 1 is accepted

Sort by
0
Darwin
Top achievements
Rank 1
answered on 21 Jan 2013, 05:43 PM
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.
0
Maria Ilieva
Telerik team
answered on 23 Jan 2013, 01:18 PM
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.
Tags
Input
Asked by
Darwin
Top achievements
Rank 1
Answers by
Darwin
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or