Click here to Skip to main content
11,798,866 members (72,851 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
Dear Friends,
                  Here i want to Write OnkeyPress Event in WebApplication in with C#.I know it is Possible in Windows But how to do in with C#.

Ex:i want to Calcute Two numbers that Result should store in Third Textbox:

Means Textbox1.text+ textbox2.text= result;

textbox3.text= result.

That Third textbox result should store KEYPRESS EVENT.


Posted 28-Aug-11 20:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is easier to in the JavaScript side of the code.
See a discussion[^] and samples using KeyPress.
archanakumari at 29-Aug-11 2:48am
Dear Abhinav,

Iam using DevExpress Control TextBox for that TextBox there is no OnkeyPress Property.In Normal Textbox Having onkeypress Property thats the Problem.SO Iam Unable to write the onkeyPress Event in DevExpress textBox.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

"That Third textbox result should store KEYPRESS EVENT "

I think You can do this on click event.
On key press you can allow user to enter only numbers.
On click on third textbox calculate your result.

<label>First number</label>    <asp:TextBox ID="TextBox1" runat="server" onkeypress="return isNumberKey(event)"></asp:TextBox> <br />
      <label>Second Number</label>  <asp:TextBox ID="TextBox2" runat="server" onkeypress="return isNumberKey(event)" ></asp:TextBox> <br />
      <label>Your result</label>   <asp:TextBox ID="TextBox3" runat="server" ReadOnly="true" onclick="javascript:check()"></asp:TextBox>

<script type="text/javascript">
   function isNumberKey(evt)
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode >

hope this works !

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

  Print Answers RSS
0 CPallini 505
1 OriginalGriff 503
2 Richard MacCutchan 321
3 Maciej Los 245
4 phil.o 244
0 OriginalGriff 2,270
1 Maciej Los 1,810
2 KrunalRohit 1,496
3 CPallini 1,425
4 Richard MacCutchan 1,109

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 29 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100