Attributes.Add OnKeyPress

3 posts, 0 answers
  1. fatih ak
    fatih ak avatar
    6 posts
    Member since:
    Jul 2009

    Posted 02 Aug 2009 Link to this post

    Hi,
    I am using radgrid which has two colum with radnumerictextbox . When i click the add new record i use the code block to find the radnumerictextbox after the finding i  add OnKeyPress Attributes to boxes .

    1      if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
    2             {  
    3                 if (e.Item.OwnerTableView.IsItemInserted)  
    4                 {  
    5                     //item is about to be inserted  
    6                     GridEditableItem dataItem = (GridEditableItem)e.Item;  
    7                     RadNumericTextBox rntBorc = (RadNumericTextBox)dataItem.FindControl("tbBorc");  
    8                     RadNumericTextBox rntAlacak = (RadNumericTextBox)dataItem.FindControl("tbAlacak");  
    9                     rntBorc.Value = 0.00;  
    10                     rntAlacak.Value = 0.00;  
    11  
    12                     if (rntBorc != null)  
    13                     {  
    14
    15                         rntBorc.Attributes.Add("onKeyPress", "return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");    
    16                     }    
    17                       
    18                     if (rntAlacak != null)  
    19                     {  
    20                         rntAlacak.Attributes.Add("OnKeyPress", "return onKeyPressAlacakInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");  
    21                     }  
    22                 }  
    23

    1 function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID)   
    2 {       
    3  
    4 }  
    5  
    6 function onKeyPressAlacakInsert(rntBorcClientID, rntAlacakClientID)   
    7 {       
    8  
    9 }  
    10       

    The Code Block above  working good .

    But i want to add OnKeyPress attributes like this

    rntBorc.Attributes.Add("onKeyPress", "return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "',event);");

    1 function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID,eventArgs)   
    2 {       
    3 var x =  eventArgs.get_inputText();
    4 }
    because i want to get character user enter ..

    but the code is not working  . How can i do this ??

    can take OnKeyyPress function 3 arguments or more ??






  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 03 Aug 2009 Link to this post

    Hello Fatih,

    Try the following code-snippet:
    <script type="text/javascript"
        function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID, args) 
        { 
            args = args || window.event; 
        } 
     
        function onKeyPressAlacakInsert(rntBorcClientID, rntAlacakClientID, args) 
        { 
            args = args || window.event; 
        }   
    </script> 

    rntBorc.Attributes.Add("onKeyPress""return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "', event);"); 
    rntAlacak.Attributes.Add("OnKeyPress""return onKeyPressAlacakInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "', event);"); 

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. fatih ak
    fatih ak avatar
    6 posts
    Member since:
    Jul 2009

    Posted 04 Aug 2009 Link to this post

    Hi Daniel,

    Thank you very much .
Back to Top