473,396 Members | 1,756 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,396 software developers and data experts.

keyDown

hie again, i have 3 textbox and i would like the user to
go to the next textbox by pressing the 'ENTER' key. i have
tried using this:

Private Sub txtRequestor_KeyDown(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles
txtRequestor.KeyDown
If e.KeyCode = Keys.Enter Then
SendKeys.Send("{TAB}")
End If
End Sub

The coding produces these errors:
1. Event 'keyDown' cannot be found
2. Name 'Keys' is not declared
3. Name 'SendKeys' is not declared

what us the cause of my problem? do i have to add in other
reference (i have already added System.Windows.Forms) so
that the keyDown event can be found? or is there another
way to do this?

Thanx!

Nov 17 '05 #1
4 8596
You must not be using Internet Explorer for your browser.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Anne" <li*******@yahoo.com> wrote in message
news:03****************************@phx.gbl...
hie again, i have 3 textbox and i would like the user to
go to the next textbox by pressing the 'ENTER' key. i have
tried using this:

Private Sub txtRequestor_KeyDown(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles
txtRequestor.KeyDown
If e.KeyCode = Keys.Enter Then
SendKeys.Send("{TAB}")
End If
End Sub

The coding produces these errors:
1. Event 'keyDown' cannot be found
2. Name 'Keys' is not declared
3. Name 'SendKeys' is not declared

what us the cause of my problem? do i have to add in other
reference (i have already added System.Windows.Forms) so
that the keyDown event can be found? or is there another
way to do this?

Thanx!

Nov 17 '05 #2
he must be using a BROWSER!

there is no such event for a text box in Asp.Net.

and the reference to SYSTEM.WINDOWS.FORMS is really puzzling. Is this a WEB
project (that's what this N.G. is for) or is this a desk-top application?

"Kevin Spencer" <ke***@SPAMMERSSUCKtakempis.com> wrote in message
news:#l**************@TK2MSFTNGP12.phx.gbl...
You must not be using Internet Explorer for your browser.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Anne" <li*******@yahoo.com> wrote in message
news:03****************************@phx.gbl...
hie again, i have 3 textbox and i would like the user to
go to the next textbox by pressing the 'ENTER' key. i have
tried using this:

Private Sub txtRequestor_KeyDown(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles
txtRequestor.KeyDown
If e.KeyCode = Keys.Enter Then
SendKeys.Send("{TAB}")
End If
End Sub

The coding produces these errors:
1. Event 'keyDown' cannot be found
2. Name 'Keys' is not declared
3. Name 'SendKeys' is not declared

what us the cause of my problem? do i have to add in other
reference (i have already added System.Windows.Forms) so
that the keyDown event can be found? or is there another
way to do this?

Thanx!


Nov 17 '05 #3
Hi Anne,

Yes, there is an onkeydown event for a text box. However, it is not on the
server side. It is on the client side, in the browser. The problem is that
you can't send keys through the browser interface programmatically. It just
isn't safe, and I don't expect that you ever will be able to. A hostile web
site could type any combination of keys on a client computer if that was so.

I mistakenly thought that you had written a client-side event handler there,
as it looks a lot like one for Internet Explorer (should have looked more
carefully). If this is a server-side event handler, you're barking way up
the wrong tree there. The good news is, you can get the effect you want on
the client side without a PostBack, and without having to use the client
keyboard. While the TAB key moves the focus to the next form field in most
browsers, you can use the JavaScript focus() method to set the focus on any
form element you wish. So, what you really need is a client-side event
handler that captures the ENTER key and sets the focus on the form element
you desire. However, be advised that this is not standard browser behavior,
and therefore may be contrary to the way that people expect their browser to
behave. Here is an example:

<script type="text/javascript"><!--
function GetEnter()
{
if (event.keyCode == 13) document.forms[0].elementName.focus();
}
// --></script>

"elementName" is the name attribute of the form element you want to shift
the focus to.

In Your textbox, just add an "onkeydown" event handler. Example:

<input type="text" name="myText" size="20" onkeydown="GetEnter()">

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Anne" <li*******@yahoo.com> wrote in message
news:0f****************************@phx.gbl...
hie david, yes, this is a web project. but i am trying 2
integrate that keyDown event from the system.windows.forms.
are u sure there's no such thing for a textbox in asp.net?
anybody else have any idea on how i can use similar
function as the keyDown?

thanx 4 all the help!
-----Original Message-----
he must be using a BROWSER!

there is no such event for a text box in Asp.Net.

and the reference to SYSTEM.WINDOWS.FORMS is really

puzzling. Is this a WEB
project (that's what this N.G. is for) or is this a desk-

top application?

"Kevin Spencer" <ke***@SPAMMERSSUCKtakempis.com> wrote in

message
news:#l**************@TK2MSFTNGP12.phx.gbl...
You must not be using Internet Explorer for your browser.
HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Anne" <li*******@yahoo.com> wrote in message
news:03****************************@phx.gbl...
> hie again, i have 3 textbox and i would like the user to > go to the next textbox by pressing the 'ENTER' key. i have > tried using this:
>
> Private Sub txtRequestor_KeyDown(ByVal sender As
> System.Object, ByVal e As
> System.Windows.Forms.KeyEventArgs) Handles
> txtRequestor.KeyDown
> If e.KeyCode = Keys.Enter Then
> SendKeys.Send("{TAB}")
> End If
> End Sub
>
> The coding produces these errors:
> 1. Event 'keyDown' cannot be found
> 2. Name 'Keys' is not declared
> 3. Name 'SendKeys' is not declared
>
> what us the cause of my problem? do i have to add in other > reference (i have already added System.Windows.Forms) so > that the keyDown event can be found? or is there another > way to do this?
>
> Thanx!
>

.

Nov 17 '05 #4

hie kevin,
thanx 4 the reply, and yes, at the time i was reading ur
explanation and solution, i was able to find another
solution similar to yours using javascript :) thanx once
again!
-----Original Message-----
Hi Anne,

Yes, there is an onkeydown event for a text box. However, it is not on theserver side. It is on the client side, in the browser. The problem is thatyou can't send keys through the browser interface programmatically. It justisn't safe, and I don't expect that you ever will be able to. A hostile website could type any combination of keys on a client computer if that was so.
I mistakenly thought that you had written a client-side event handler there,as it looks a lot like one for Internet Explorer (should have looked morecarefully). If this is a server-side event handler, you're barking way upthe wrong tree there. The good news is, you can get the effect you want onthe client side without a PostBack, and without having to use the clientkeyboard. While the TAB key moves the focus to the next form field in mostbrowsers, you can use the JavaScript focus() method to set the focus on anyform element you wish. So, what you really need is a client-side eventhandler that captures the ENTER key and sets the focus on the form elementyou desire. However, be advised that this is not standard browser behavior,and therefore may be contrary to the way that people expect their browser tobehave. Here is an example:

<script type="text/javascript"><!--
function GetEnter()
{
if (event.keyCode == 13) document.forms [0].elementName.focus();}
// --></script>

"elementName" is the name attribute of the form element you want to shiftthe focus to.

In Your textbox, just add an "onkeydown" event handler. Example:
<input type="text" name="myText" size="20" onkeydown="GetEnter()">
HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.

"Anne" <li*******@yahoo.com> wrote in message
news:0f****************************@phx.gbl...
hie david, yes, this is a web project. but i am trying 2
integrate that keyDown event from the system.windows.forms. are u sure there's no such thing for a textbox in asp.net? anybody else have any idea on how i can use similar
function as the keyDown?

thanx 4 all the help!
>-----Original Message-----
>he must be using a BROWSER!
>
>there is no such event for a text box in Asp.Net.
>
>and the reference to SYSTEM.WINDOWS.FORMS is really

puzzling. Is this a WEB
>project (that's what this N.G. is for) or is this a
desk- top application?
>
>"Kevin Spencer" <ke***@SPAMMERSSUCKtakempis.com> wrote
in message
>news:#l**************@TK2MSFTNGP12.phx.gbl...
>> You must not be using Internet Explorer for your

browser.
>>
>> HTH,
>>
>> Kevin Spencer
>> Microsoft FrontPage MVP
>> Internet Developer
>> http://www.takempis.com
>> Some things just happen.
>> Everything else occurs.
>>
>> "Anne" <li*******@yahoo.com> wrote in message
>> news:03****************************@phx.gbl...
>> > hie again, i have 3 textbox and i would like the
user to
>> > go to the next textbox by pressing the 'ENTER'
key. i have
>> > tried using this:
>> >
>> > Private Sub txtRequestor_KeyDown(ByVal sender As
>> > System.Object, ByVal e As
>> > System.Windows.Forms.KeyEventArgs) Handles
>> > txtRequestor.KeyDown
>> > If e.KeyCode = Keys.Enter Then
>> > SendKeys.Send("{TAB}")
>> > End If
>> > End Sub
>> >
>> > The coding produces these errors:
>> > 1. Event 'keyDown' cannot be found
>> > 2. Name 'Keys' is not declared
>> > 3. Name 'SendKeys' is not declared
>> >
>> > what us the cause of my problem? do i have to add
in other
>> > reference (i have already added
System.Windows.Forms) so
>> > that the keyDown event can be found? or is there

another
>> > way to do this?
>> >
>> > Thanx!
>> >
>>
>>
>>
>
>
>.
>

.

Nov 17 '05 #5

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

Similar topics

34
by: Andrew DeFaria | last post by:
I thought this would be fairly straight forward but apparently it's not. Given the following html file: <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head>...
3
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
3
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
3
by: Colin McGuire | last post by:
Hi, can I ask what I should be doing below. For some reason the method KeyDown doesn't exist in MyBase. Thank you Colin Private Sub TextBox1_KeyDown(ByVal sender As Object, _ ByVal e As...
0
by: Peter | last post by:
I have a VB6 program which can receive Keydown events on an ActiveX control. The ActiveX control can't fire keydown events so I put a picturebox below the ActiveX control. I write codes in...
4
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As...
1
by: fripper | last post by:
I have a VB 2005 windows app and I want to recognize keydown events. I have a form key down event handler but it does not get control when a key is depressed. In playing around I found that if I...
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
3
by: win | last post by:
when the cursor is in a textbox, only coding in the keydown event of the textbox triggered, the coding in the keydown event of the form does not triggered! Problem: I need to change a VB6 program...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.