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

RadMaskedTextBox moves caret on focus even if SelectionOnFocus="None"

3 Answers 274 Views
Input
This is a migrated thread and some comments may be shown as answers.
Dev LIPIX
Top achievements
Rank 1
Dev LIPIX asked on 21 Sep 2010, 09:39 PM
Hello,

I need to be able to keep the caret in the same location on a masked textbox when a user leaves our webpage (switches tabs) and comes back.

Currently, if the user enters some text, '123', and then goes to a different tab and comes back, the caret does not remain after the '3'.  It has moved to the end of the mask.
<telerik:RadMaskedTextBox ID="RMTBZip" runat="server" Mask="#####-####" SelectionOnFocus="None" />

This happens regardless of whether I set the SelectionOnFocus attribute to "None" or not.

A standard asp textbox keeps the caret in the same location.  If I type "test" and leave the caret between the 'e' and the 's'.  Tab away and come back, the caret is still in the same location.  Is there another attribute I need to use in order to replicate this functionality?  Or in other words, stop the caret from moving?

Regards,
Chris

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 27 Sep 2010, 08:52 AM
Hello Dev,

One possible option could be to get the caret position on MouseClick or on KeyUp event of the input :
function getCursorPosition(sender) {   
    var cursorPosition = sender.get_caretPosition()   
         
}  

After that you should focus the input control on PageLoad event and set the cursor position back OnFocus event of the MaskedTextBox.

Regards,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dev LIPIX
Top achievements
Rank 1
answered on 27 Sep 2010, 06:41 PM
Hello,

Thank you for the response, however I feel that I was not clear in my original question.  I may have confused matters by using the RadMaskedTextBox in my example.

This happens with your RadTextBox control as well.

<telerik:RadTextBox ID="RTBZip" runat="server"></telerik:RadTextBox>

If I type 'test' into this textbox and then place the cursor between the 'e' and 's' characters.  When I return focus back to the page, the cursor has been moved to the end.  If I set the SelectionOnFocus property to CaretToBeginning the cursor is moved to the beginning.  The standard asp.net control does not move the cursor in this manner.  Since it appears that you have added this functionality to the standard web input control, I was assuming that I could 'turn it off' and return the control to its standard behavior.

Is there an property I can use to do this?

Regards,
Chris
0
Maria Ilieva
Telerik team
answered on 30 Sep 2010, 10:00 AM
Hello,

Note that the RadInput controls are not equal to the regular asp TextBox as it is rendering on the page as span and not as single input. The specific of the control is the reason for the behavior you are facing and it is the default one for RadInput. Currently possible option for workaround this is to use the suggestion proposed in the previous post. Another option is to use regular asp TextBoxes extended with RadInputManager


Greetings,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Input
Asked by
Dev LIPIX
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Dev LIPIX
Top achievements
Rank 1
Share this question
or