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

RadnumericTextBox ClientEvents OnKeyPress in Safari not working

2 Answers 197 Views
Input
This is a migrated thread and some comments may be shown as answers.
Mansi
Top achievements
Rank 1
Mansi asked on 11 Jun 2010, 01:53 PM
Hi,
I am working with a .net gridview and with many radnumerictextboxes inside the grid. 
I have to move the focus to the next row, instead of next column (which is by default), on tab press in textbox. So for that I have fired onkeypress event of textbox, and if keychar is tab then, it will focus on the textbox below instead of beside box.
Here is a client side code and the onkeypress event. This code works well in Mozilla.

 <asp:TemplateField HeaderText="Par" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="29px" 
                                        ItemStyle-Width="29px" > 
                                        <ItemTemplate> 
                                            <telerik:radnumerictextbox runat="server" id="txtSinglePar" width="25px"   onfocus="HasFocus(this)" 
                                                emptymessage="Par">      
                                                 <ClientEvents OnKeyPress="MoveToNextTextBox" />                                   
                                              <NumberFormat DecimalDigits="0" GroupSeparator="" />    </telerik:radnumerictextbox> 
                                        </ItemTemplate> 
                                    </asp:TemplateField> 

HasFocus() works well.

 function HasFocus(TextBox) {      
       textBoxWithFocus = TextBox;     
    } 


And this is JS function of focusing on the next control, according to required logic.

function MoveToNextTextBox(sender, args) 
     { 
        //IF TAB KEY HAS BEEN PRESSED 
         if (args.get_keyCode() == 9) 
         { 
            var str = textBoxWithFocus.id.replace("_text", ""); 
            var id = str.substring(str.indexOf("_ctl"), str.indexOf("_txt")); 
            //GET THE NUMBER OF THE ROW IN GRIDVIEW 
            idid = id.replace("_ctl", ""); 
            newId = parseFloat(id) + parseFloat(01); 
            if (parseInt(newId) < 9) { 
                newId = "0" + newId; 
            } 
            var prevID = str.replace(id, newId); 
 
            if (parseFloat(id) < 9
             { 
                prevIDprevID = prevID.replace("_ctl", "_ctl0"); 
                prevIDprevID = prevID.replace("_ctl00", "_ctl0"); 
            } 
            var newCtl = document.getElementById(prevID); 
 
            if (newCtl != null && $find(newCtl.id) != null)  
            { 
                $find(newCtl.id).focus();                                                  
            }               
           args.set_cancel(true);  
        } 
 
    } 

While in Mozilla, it moves to the control in next row, in safari it does not. What is the reason?

2 Answers, 1 is accepted

Sort by
0
Mansi
Top achievements
Rank 1
answered on 14 Jun 2010, 07:40 AM
  <telerik:radnumerictextbox runat="server" id="txt111" width="25px" emptymessage="Par"
    <ClientEvents OnKeyPress="ShowMsg" />               
 </telerik:radnumerictextbox> 
 
 function ShowMsg(sender, args) { 
           alert(args.get_keyCharacter()); 
           alert(args.get_keyCode()); 
       } 

Above sample does not work when user has pressed the tab key (In IE and Safari).
How to know that tab key has been pressed? It just moves to the next control, without alert.  Can anybody answer this question?




0
Iana Tsolova
Telerik team
answered on 16 Jun 2010, 02:35 PM
Hi Mansi,

In order to achieve your goal, I suggest that you handle the onkeydown event:

<telerik:radnumerictextbox runat="server" id="txt111" width="25px" 
    onkeydown="ShowMsg(this, event);" emptymessage="Par">           
</telerik:radnumerictextbox>
    
function ShowMsg(sender, args) {  
    alert(args.keyCode);  
}

i hope this helps.

Kind regards,
Iana
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
Mansi
Top achievements
Rank 1
Answers by
Mansi
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or