Click here to Skip to main content
12,818,664 members (28,199 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# 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 21: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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170308.1 | Last Updated 29 Aug 2011
Copyright © CodeProject, 1999-2017
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