I have some ASP.NET Web App pages on which there are web forms with
textboxes and buttons for 'Cancel' and 'Submit' and such. All works great.
However, it a user uses the ENTER key in either of two textboxes, the
postback 'falls through' to one of the 'Cancel' button handlers, and exits
the application. Oddly, I can't use anything in the Cancel routine to check
whether the ENTER key was hit, since the sender object is always the Cancel
key itself. This behavior is unwanted, and I can't figure out how to trap
the ENTER hey strokes either on the client or server side.
On some pages I have been able to get the ENTER key to fall through to a
Submit button, which makes more sense, but I still would like to be able to
process the postback depending on the ENTER key usage or not.
What approach should I be using?
Bob 2 1498
Bob,
In the html view of the aspx page, make sure the Submit button appears
before the Cancel button. In that way, the Enter will go to the Submit button.
"Robert Dickow" wrote: I have some ASP.NET Web App pages on which there are web forms with textboxes and buttons for 'Cancel' and 'Submit' and such. All works great. However, it a user uses the ENTER key in either of two textboxes, the postback 'falls through' to one of the 'Cancel' button handlers, and exits the application. Oddly, I can't use anything in the Cancel routine to check whether the ENTER key was hit, since the sender object is always the Cancel key itself. This behavior is unwanted, and I can't figure out how to trap the ENTER hey strokes either on the client or server side.
On some pages I have been able to get the ENTER key to fall through to a Submit button, which makes more sense, but I still would like to be able to process the postback depending on the ENTER key usage or not.
What approach should I be using?
Bob
Robert Dickow wrote: I have some ASP.NET Web App pages on which there are web forms with textboxes and buttons for 'Cancel' and 'Submit' and such. All works great. However, it a user uses the ENTER key in either of two textboxes, the postback 'falls through' to one of the 'Cancel' button handlers, and exits the application. Oddly, I can't use anything in the Cancel routine to check whether the ENTER key was hit, since the sender object is always the Cancel key itself. This behavior is unwanted, and I can't figure out how to trap the ENTER hey strokes either on the client or server side.
On some pages I have been able to get the ENTER key to fall through to a Submit button, which makes more sense, but I still would like to be able to process the postback depending on the ENTER key usage or not.
What approach should I be using?
Bob
Some background info:
When you hit the enter-key in the browser, that browser simulates a click
on the "default button". The browser then sends a request to the server as if that
button was clicked.
The server then has no way to know *how* that button was clicked. Asp.Net
just registers a "click" on your button.
See www.MetaBuilders.com, look for DefaultButtons. That might help.
Hans Kesting This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Scott |
last post by:
I'm using C# to build an application.
1) I have two windows forms, A and B.
2) A uses a DataSet read from SQL server.
3) The user presses a button on A to open B.
4) B is passed a pointer to the DataSet.
5) While in B, tables in the Dataset are bound to combo
box controls.
6) While in B, I add handlers to capture the
SelectedIndexChanged event
|
by: styler |
last post by:
I am having difficulty with the page located here:
http://tinyurl.com/2zwa9
I am creating a number of image sets (some left-, some right-aligned; an
example of the right-aligned is shown the first figure below) in which
the text accompanying the image sets flows down around them. The image
sets have a single image on top and two immediately below. To create the
effect, I contain the image on top in a DIV and float it, and the bottom...
|
by: Simon Wigzell |
last post by:
How can I interrupt the enter key so it won't trigger unwanted events on my
web page? I have tried this:
var defaultEventHandler = obj.getEvent("onkeydown");
var myEventHandler = function(event){
if(event.keyCode==13){
alert(obj.getProperty("selection/index"));
}
else{
|
by: Empire City |
last post by:
My windows form has some text boxes and a two buttons, Button1 and Button2.
The TAB key goes from field to field. When the user presses the RETURN key I
want the focus to be moved to Button1. Is there an easy way to do this or
would I have to check for all keypresses in an event somewhere and manually
set the focus on Button1 if the RETURN key was hit. Is so, which event would
that be?
|
by: ewillyb |
last post by:
Hi,
ASP.NET has some interesting behavior when the user hits the Enter key.
If there are multiple ASP:Buttons (rendered as HTML submits) on the
form, when the user hits enter, the first button's click event will
fire and the page will submit.
I have a series of pages with Previous and Next navigational Btns. The
Previous button is the first button, so when the user hits enter, the
previous page is served up. Enter should result in...
| |
by: Adam J. Schaff |
last post by:
I have noticed that if a user closes a form via pressing return (either
while the OK button has focus or if AcceptButton is set to OK for the form)
then the "ENTER" keypress event fires ON THE CALLING FORM! This is very bad
for me, because in my application, Form1 responds to an ENTER keypress by
calling Form2. If the user closes Form2 via an ENTER, then Form1 just
reopens it again, kind of trapping the user in Form2 (they can still close...
|
by: mk |
last post by:
Hi
I'v got the following javascript (part of it) that works with the event
onmouseup:
// Attach event handlers to all images within container
LICollection=document.getElementById("MDME").getElementsByTagName("LI");
if (LICollection!=null)
{ for (l=0; l<LICollection.length; l++)
{LICollection.item(l).onmouseup=onMouseUpHandler;}
|
by: Marc |
last post by:
Hi,
I want my user to be able to rename a button control by selcting rename
from a menu. This then opens a text box in which to enter the new name
in. I want the button control to inherit the name when the enter key is
|
by: Zytan |
last post by:
I want the same function to be run whether you press Enter or double
click the listbox. It seems really verbose to write both handlers to
both events everytime, even if they both call the same function, or
one calls the other.
Isn't there an event for 'ListBox selection selected' that is
automatically called by ALL the standard GUI ways of doing it? C'mon,
this is C#, we aren't supposed to be programming the GUI. There has
to be such...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |