Altering function of keypress for listbox

J

Jeff

....still new at this. ...hopefully a simple question

Is there some practical way of altering the function of a keypress in Visual Web.net 2005 using VB without causing a postback on
each keypress? For example: A have a listbox with a number of selections. The up and down keyboard keys change the indicated listbox
selection and by default the <tab> key takes the focus away from the listbox and onto a button that will submit the selection. I'm
attempting to also have the <enter> key take the focus away from the listbox and onto the button, so that two pushes on the <enter>
key will submit the listbox selection (a drop down list will act in this manner by default).

Is this possible?

Thanks

Jeff
 
J

Jay B. Harlow [MVP - Outlook]

Jeff,
If its possible, I suspect it would be, you would need to use Javascript to
do it. Unfortunately Javascript is not my strong point.

I would recommend you ask "down the hall" in one of the
microsoft.public.dotent.framework.aspnet.* newsgroups.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


|
| ...still new at this. ...hopefully a simple question
|
| Is there some practical way of altering the function of a keypress in
Visual Web.net 2005 using VB without causing a postback on
| each keypress? For example: A have a listbox with a number of selections.
The up and down keyboard keys change the indicated listbox
| selection and by default the <tab> key takes the focus away from the
listbox and onto a button that will submit the selection. I'm
| attempting to also have the <enter> key take the focus away from the
listbox and onto the button, so that two pushes on the <enter>
| key will submit the listbox selection (a drop down list will act in this
manner by default).
|
| Is this possible?
|
| Thanks
|
| Jeff
|
|
|
|
|
| --
|
|
 
C

Cor Ligthert [MVP]

Jeff,

Not despite but in addition of Jay's answer, I think you will hardly find
any JavaScript for this.

If needed you can add it in VBNet, using the addattributes or
registratejavascript attributes. But you will probably not find good
Javascript, The reason is that you try to change the standard behaviour of
all the mozila compatible browser UI, something we are so glad of that it
exist.

This means that all or at least most of your current website users will hate
you shorter or later and try to avoid your website.

Just my thougth reading Jays message and thinking why I did not give an
answer on your question.

Cor
 
J

Jay B. Harlow [MVP - Outlook]

Cor,
| If needed you can add it in VBNet, using the addattributes or
| registratejavascript attributes. But you will probably not find good
| Javascript, The reason is that you try to change the standard behaviour of
| all the mozila compatible browser UI, something we are so glad of that it
| exist.
I agree. Mozila, vs IE 6-, IE 7+, vs Opera, vs whatever may mean he will
need browser specific Javascript. Or worse specific browsers may just not
support it.

He should be able use Request.Browser to find out which browser, what
version of browser, what version of DOM, what version of Javascript... the
client is using:

http://msdn2.microsoft.com/en-us/library/system.web.httprequest.browser.aspx


Rather then avoid a feature I try to ensure that it "degrades gracefully".
For example I use Request.Browser on my web site to decide if copying on my
samples pages is supported: IE gets the copy button, Firefox doesn't. As the
copy button uses IE specific functionality. (If you have Firefox et al copy
to clipboard java script I would love to use it).

Although I agree, I might avoid his site if his web select control didn't
behave as other web select controls...

Reading his message just now, wont making the button the "submit" button
cause it to submit the page? Without needing to add code. I may need to
review this closer tonight.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Jeff,
|
| Not despite but in addition of Jay's answer, I think you will hardly find
| any JavaScript for this.
|
| If needed you can add it in VBNet, using the addattributes or
| registratejavascript attributes. But you will probably not find good
| Javascript, The reason is that you try to change the standard behaviour of
| all the mozila compatible browser UI, something we are so glad of that it
| exist.
|
| This means that all or at least most of your current website users will
hate
| you shorter or later and try to avoid your website.
|
| Just my thougth reading Jays message and thinking why I did not give an
| answer on your question.
|
| Cor
|
|
| "Jeff" <[email protected]> schreef in bericht
| | >
| > ...still new at this. ...hopefully a simple question
| >
| > Is there some practical way of altering the function of a keypress in
| > Visual Web.net 2005 using VB without causing a postback on
| > each keypress? For example: A have a listbox with a number of
selections.
| > The up and down keyboard keys change the indicated listbox
| > selection and by default the <tab> key takes the focus away from the
| > listbox and onto a button that will submit the selection. I'm
| > attempting to also have the <enter> key take the focus away from the
| > listbox and onto the button, so that two pushes on the <enter>
| > key will submit the listbox selection (a drop down list will act in this
| > manner by default).
| >
| > Is this possible?
| >
| > Thanks
| >
| > Jeff
| >
| >
| >
| >
| >
| > --
|
| >
|
|
 
J

Jeff

Jay B. Harlow said:
Although I agree, I might avoid his site if his web select control didn't
behave as other web select controls...

Reading his message just now, wont making the button the "submit" button
cause it to submit the page? Without needing to add code. I may need to
review this closer tonight.


I should clarify that this was intended not for a public use web site, but rather for something very specific to use for collecting
data from people who were invited (and paid) to participate. I'm attempting to take them as rapidly as possible through a series of
questions/answers without jumping from the keyboard to the mouse and back again. It isn't practical to install an application on
their machines, so we are using a browser based interface. So yes, you are correct that this would not generally be a good idea for
another use.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top