Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Keypress event handler (http://www.go4expert.com/forums/keypress-event-handler-t757/)

markyjj 25Apr2006 16:17

Keypress event handler
 
Am currently trying to create code that clears a text box after a message box is shown when a nonnumeric digit is entered. The code am using doesnt clear the text field as shown below:
Code: C#

if(Char.IsDigit(e.KeyChar) == false)
            {
                txtStudID.Focus();
                txtStudID.Text = "";
               MessageBox.Show("Please enter a numeric value to continue");
               
               
            }

Thanks for any help

shabbir 25Apr2006 20:54

Re: Keypress event handler
 
Does it show the message box.

pradeep 29Jan2007 17:27

Re: Keypress event handler
 
Oh! A simple fix on line 7 would fix that, change line 7 to this

Code: javascript

if (document.layers || e.which) { pressedKey = e.which; }



All times are GMT +5.5. The time now is 10:45.