Click here to Skip to main content
15,919,774 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Can you help me onkeypress event in java script


C#
function kgstotons()
  {
  var quantity=parseFloat(document.getElementById('t;%=txtQuantity.ClientID%gt;').value);


       if(isNaN(quantity)!=true  )
       {

            document.getElementById('<%=lblTons.ClientID%gt;').innerText = parseFloat(document.getElementById('<%=txtQuantity.ClientID%>').value) / parseFloat(1000);

           return false;
       }
  }


.cs file

txtQuantity.Attributes.Add("onkeydown", "javascript:return kgstotons();");
Posted
Comments
thatraja 16-Feb-12 6:16am    
What's the error message?

You probably can find your answer here: http://forums.asp.net/t/934912.aspx/1[^]

Good luck!
 
Share this answer
 
you have to remove "Return" from the event binding. update your server side code as below.

C#
txtQuantity.Attributes.Add("onkeydown", "kgstotons();");
 
Share this answer
 
Hi, use below code:

C#
txtQuantity.Attributes.Add("onkeyup", "javascript:return kgstotons();");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900