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

Attributes.Add OnKeyPress

2 Answers 71 Views
Input
This is a migrated thread and some comments may be shown as answers.
fatih ak
Top achievements
Rank 1
fatih ak asked on 02 Aug 2009, 07:54 PM
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 .

     if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                if (e.Item.OwnerTableView.IsItemInserted)  
                {  
                    //item is about to be inserted  
                    GridEditableItem dataItem = (GridEditableItem)e.Item;  
                    RadNumericTextBox rntBorc = (RadNumericTextBox)dataItem.FindControl("tbBorc");  
                    RadNumericTextBox rntAlacak = (RadNumericTextBox)dataItem.FindControl("tbAlacak");  
                    rntBorc.Value = 0.00;  
                    rntAlacak.Value = 0.00;  
 
                    if (rntBorc != null)  
                    {  
                        rntBorc.Attributes.Add("onKeyPress", "return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");    
                    }    
                      
                    if (rntAlacak != null)  
                    {  
                        rntAlacak.Attributes.Add("OnKeyPress", "return onKeyPressAlacakInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");  
                    }  
                }  

function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID)   
{       
 
}  
 
function onKeyPressAlacakInsert(rntBorcClientID, rntAlacakClientID)   
{       
 
}  
      

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);");

function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID,eventArgs)   
{       
var x =  eventArgs.get_inputText();
}
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 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Aug 2009, 07:54 AM
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.
0
fatih ak
Top achievements
Rank 1
answered on 04 Aug 2009, 06:53 PM
Hi Daniel,

Thank you very much .
Tags
Input
Asked by
fatih ak
Top achievements
Rank 1
Answers by
Daniel
Telerik team
fatih ak
Top achievements
Rank 1
Share this question
or