Home All Groups Group Topic Archive Search About
Author
8 Nov 2006 10:36 AM
Julia
Hi

I have a user control including a button (and some more stuff). When I use
the user control on an asp.net page I would like the button on the user
control never to be selected.

The problem now is when i press enter the button is pressen. I would like to
force the user to use the mouse to press the button. How do I do this?

Thanks
Julia

Author
8 Nov 2006 3:36 PM
David Longnecker
I've worked around this two ways (as, honestly, I don't know of a way to
truly stop the Enter key from pressing a button.  I believe that's a client-size
functionality, not server-side):

1. Tie a validation to the button to require that the form cannot be submitted
(thus the button not activated) until something occurs on the page.  I've
read other articles where they've used JavaScript to do something similar.

2. Use ImageButtons and images that look similar to your themed or stylized
form buttons.  As far as I know, ImageButtons don't activate via the Enter
key and you can proceed through your page logic via the ImageButton_Click
method.

-dl

---
David Longnecker
Web Developer
http://blog.tiredstudent.com

Show quoteHide quote
> Hi
>
> I have a user control including a button (and some more stuff). When I
> use the user control on an asp.net page I would like the button on the
> user control never to be selected.
>
> The problem now is when i press enter the button is pressen. I would
> like to force the user to use the mouse to press the button. How do I
> do this?
>
> Thanks
> Julia