Submitting Form by pressing the "ENTER" key
--------------------------------------------------------------------------------
Hi:
I have a search form in my application which has 4 dropdown list controls, one text box, one "GO" button, one "reset" button. When the "GO" button is clicked the form gets submitted and the results page is displayed. When I press the "enter" key nothing happens. I want to submit the form by pressing the "enter" key also. I have placed <input type="text" style="display: none"> after the <form> tag in the HTML section. Now if my cursor is in the text box only then the "enter" key press works. But in our case the text box is for "keyword" or "phrase". Most of the times the user doesn't use it, so the cursor is rarely there. We don't have ASP.NET 2.0, so I can't use the defaulltbutton property. Can anyone give me any suggestions? Thanks in advance.
Roxana
4 3872
As per my understanding.
Go to properties of that button, selete the tab index and set it.
TabIndex is something which is selection order of controls .
so go to all the controls, like for example
set textbox tab to 1
set button tab to 2
so immediately after text box it sill select the button
U can also search in the web about the above.
I hope it helps.
Hi:
Thanks for your prompt reply. I tried that but did not work. Isn't tab index for the tab key? I want to use the "enter" key. Thanks again.
Roxana
As per my understanding.
Go to properties of that button, selete the tab index and set it.
TabIndex is something which is selection order of controls .
so go to all the controls, like for example
set textbox tab to 1
set button tab to 2
so immediately after text box it sill select the button
U can also search in the web about the above.
I hope it helps.
So from the text box, you want to be able to hit 'enter' and perform some action, correct? If this is the case.. you need to have a procedure which catches the key_down even for your text box.
the procedure will have 2 parameters passed in, one of which is the key down event (ByVal e As System.Windows. Forms.KeyEventA rgs). to catch if the 'enter' key is pressed, do
if(e.keycode = keys.enter) then
'do some action
end if
Hi:
Thanks for your reply but I have just solved my problem by some other way. Actually my problem was to make the "enter" key work when the cursor is not in the textbox. When the cursor is in the textbox the "enter" key works. This was accomplished by putting an invisible textbox by inserting
<input type="text" style="DISPLAY: none"> in between the <form> and </form> tags. It was necessary because I have only one textbox. What I did today is added the following in between the <HEAD> and </HEAD>tags.
<script language="javas cript">
<!--
function SetFocus()
{
document.Form1['txtTitle'].focus();
}
window.onload = SetFocus;
// -->
</script>
This sets the cursor in the textbox when the page loads. Then I inserted the property AutoPostBack="T rue" in all my 4 dropdownlist controls. Now whatever I do in the form the cursor goes right back to the textbox, and when I hit "enter" the form gets submitted. I am feeling so great today I felt like sharing this with everyone.
So from the text box, you want to be able to hit 'enter' and perform some action, correct? If this is the case.. you need to have a procedure which catches the key_down even for your text box.
the procedure will have 2 parameters passed in, one of which is the key down event (ByVal e As System.Windows. Forms.KeyEventA rgs). to catch if the 'enter' key is pressed, do
if(e.keycode = keys.enter) then
'do some action
end if
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: EBG |
last post by:
I have a simple email form on my site but getting screwy results because I
know alot of users are hitting "enter" instead of tab when doing the form.
When they hit enter the entire form is submitted whether it's finished or
not.
Is there an easy way to correct this?
My site only cares about IE.
|
by: Simon Wigzell |
last post by:
Is there a way to prevent a form submitting when you press enter on a text
field? Some people press enter when they finish typing in a text field out
of habit I guess unconcsciously thinking it will take them to the next
field. Instead it submits the form and this causes all kinds of problems in
my case. Any javascript solution?
|
by: Byron McClain |
last post by:
.... is being consumed. I added an event handler for the "keypress" event
and my delegate
never gets executed. Why? I am trying to catch the "enter" key pressed
event to prevent
the DataGrid from going to currentRow + 1. Instead I want it to give focus
to the next cell (currentCol + 1) to the
right if not at the end of the row.
Example:
|
by: Cindy |
last post by:
Hi all you smarties out there,
I'm having a little conundrum with my asp.net page
Scenario:
I have a form (asp.net) with no code behind (as yet).
I have placed a javascript function on a server side textbox control
to do something - eg change the words on label - when the key pressed
is the "enter" key.
I can see the label change to what i expect ----- BUT .... then the
|
by: laredotornado |
last post by:
Hi,
I have a very simple form and I would like on Firefox and IE for the
form to submit upon the user pressing enter in the textfield. Right
now, I have
<script type="text/javascript">
function search() {
var search = document.getElementById('Search');
location = "search_response.php?Search=" + escape(search.value);
| |
by: roxanaislam |
last post by:
Hi:
I have a search form in my application which has 4 dropdown list controls, one text box, one "GO" button, one "reset" button. When the "GO" button is clicked the form gets submitted and the results page is displayed. When I press the "enter" key nothing happens. I want to submit the form by pressing the "enter" key also. I have placed <input type="text" style="display:none"> after the <form> tag in the HTML section. Now if my cursor...
|
by: Zytan |
last post by:
I can handle DoubleClick on a ListBox to respond, not when the
selection changes, but when you double click one to invoke an action.
This is the same as using the keys to move the selection, then
pressing Enter. But, of course, DoubleClick doesn't automatically
handle that.
Is there any way to handle ALL standard UI at once, rather than
checking for DoubleClick and for Enter press manually?
Zytan
|
by: vanipuranam |
last post by:
When the user presses "Enter" from the keyboard instead of clicking the "Go" button I would like to have the code that would have run by clicking the button work the same way when they press the Enter key.
|
by: Simon Verona |
last post by:
Sorry for the repost, but this group seems to be more "active" than the
group that I posted my question, and it's probably as valid here as there!
I have a usercontrol, which contains a textbox (as well as other controls).
The textbox is set for multiline, so it *should* accept an Enter Key to move
down to the next line.
However, I'm finding that if I put the control onto a form which has a
default Accept button set, then pressing...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |