473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

e.KeyCode in KeyDown

Why does the following code

char l_ch = Convert.ToChar(
e.KeyCode);

give me the value 226 ('â') and not 60 ('<') when I press '<' ?
What am I doing wrong? I have also tried

char l_ch = Convert.ToChar(
e.KeyCode,
CultureInfo.InvariantCulture);
Nov 28 '06 #1
2 7529
I'm interested in the answer to the question I posted, but what I really want
to do is to make sure that my text box cannot contain certain characters like
< | * ? : \ / ". In ASP .NET there is a special control for this, called a
validator, but I cannot find a validator like that in my toolbox. Any
suggestions?

"Joachim" wrote:
Why does the following code

char l_ch = Convert.ToChar(
e.KeyCode);

give me the value 226 ('â') and not 60 ('<') when I press '<' ?
What am I doing wrong? I have also tried

char l_ch = Convert.ToChar(
e.KeyCode,
CultureInfo.InvariantCulture);
Nov 28 '06 #2
You can take a look at the same pattern used by Windows controls these have
virtual method called IsInputChar() en IsInputKey() where you evaluate the
key pressed and return either true or false. But mostly these kinds of
things are implemented using a regular expression.

Gabriel

"Joachim" <Jo*****@discussions.microsoft.comwrote in message
news:2F**********************************@microsof t.com...
I'm interested in the answer to the question I posted, but what I really
want
to do is to make sure that my text box cannot contain certain characters
like
< | * ? : \ / ". In ASP .NET there is a special control for this, called
a
validator, but I cannot find a validator like that in my toolbox. Any
suggestions?

"Joachim" wrote:
>Why does the following code

char l_ch = Convert.ToChar(
e.KeyCode);

give me the value 226 ('â') and not 60 ('<') when I press '<' ?
What am I doing wrong? I have also tried

char l_ch = Convert.ToChar(
e.KeyCode,
CultureInfo.InvariantCulture);

Nov 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: oeyvind toft | last post by:
How do I capture the ctrl keypress? Is it possible for js to intercept the ctrl-n combination and prevent the creation of a new IE window?? (Have 3 huge books on js and none of them mention...
17
by: Julia Briggs | last post by:
Are there any gotchas using if (event.keyCode==8)? I understand that to represent backspace, but it doesn't work. I am running Windows XP, using a typical keyboard - but no luck in detecting...
4
by: Thomas Christensen | last post by:
I'm trying to figure out what key the user pressed using a Danish keyboard layout. charCodeAt returns the correct number, but event.keyCode returns a wrong number, when using one of the keys that...
1
by: kids_pro | last post by:
Hi there, I want to capture the last key press in a textBox. So I decided to use KeyDown event and from the KeyEventArgs I read the e.KeyCode But when I type small letter the e.KeyCode always...
2
by: melanieab | last post by:
Hi, Just checking to see if there's anything I can possibly do to allow for the recognition of the Tab key being pressed. On the KeyDown event I've tried: if (e.KeyCode == Keys.Tab), if...
2
by: strah | last post by:
I am trying to detect when a user uses Tab key while with the KeyDown event of the combobox. It seems to work fine with all the Keys (Enter, T, ...) but not with the Tab key (e.KeyCode = Keys.Tab)....
2
by: Alberto | last post by:
Could you tell me witch is the difference between keycode, keyvalue and keydata in a keydown event? keyvalue is always the ascii code? thank you
3
by: Pugi! | last post by:
I got this (piece of) script from 'DHTML Utopia - Modern Webdesign - Using Javascript & DOM'. function aKeyWasPressed(e) { if (window.event) { var key = window.event.keyCode; } else { var key...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
6
by: mingchin.AT | last post by:
Hi, In Javascript, the simple way to check user input is to get the keycode. But for cross browser, its seems we need to have two different keycodes for the same key. There is a web page for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.