Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 8th, 2007, 04:42 AM
Authorized User
 
Join Date: Jan 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default on keypress (enter) jump to button

hi guys,ur help is needed yet another time.I have an asp.net webform in which the user can search.I want to apply something to directly jump to the search button when the user enters any criteria...ur help is appreciated

 
Old January 8th, 2007, 09:37 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I use a similiar function, however, it prevents a user from pressing the enter button and having it submit a form.

function keyPress(e)
{
    var pressedKey = document.all? window.event.keyCode:e.which;
    return pressedKey != 13;
}
document.onkeypress = keyPressed;
if (document.layers) document.captureEvents(Event.KEYPRESS);

What this does is if the numerical representation of the pressed key is 13 (Key code for the enter button) it is disregarded and thus the enter button press do not do anything on the page this function is implemented on.

To do what you want, you would alter the above function so that if the keycode is 13 you would call .focus on a form element.

hth.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Enter to jump to the next text field dimeanel Visual Basic 2005 Basics 2 April 29th, 2007 01:25 AM
how to use 'Enter' button to trigger a button, thx raybristol ASP.NET 1.0 and 1.1 Basics 1 December 16th, 2005 06:56 AM
Enter key vs Click Button akibaMaila VB.NET 2002/2003 Basics 1 January 14th, 2005 12:49 PM
VB.NET Datagrid Keypress using Enter jun VS.NET 2002/2003 0 April 5th, 2004 02:38 AM
Datagrid Keypress Enter jun VS.NET 2002/2003 0 April 5th, 2004 02:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.