473,698 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pressing <ENTER> in text input control causes a postback !

Hi !

I'm working with Win 2K and Visual Studio 2003.

I have a problem because pressing <ENTER> in a text input control causes a
postback of my web form.
Here comes some example code (already stripped of most of the unnecessary
code):

----------------------------------------------------------------------------
----------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form name="Form1" method="post" action="WebForm 1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMTI3 OTMzNDM4NDs7PmA 5uGMyk9VLm/FRbF5zeYsdMA+5" />

<INPUT onkeydown="aler t('Hi, down !');" onkeyup="alert( 'Hi, up!');">
</form>
</body>
</HTML>
----------------------------------------------------------------------------
----------------------------------------------------------

The postback occurs after the onkeydown event and before the onkeyup event,
but I don't understand why.

Does anybody know a way of avoiding this undesirable automatic postback ?

Your kind help would be appreciated.

Peter
Nov 19 '05 #1
4 2883
take the action of the form:
action="WebForm 1.aspx"
This is whats causing the form to submit.

But why are you doing this onkeydown/onkeyup.
It is highly annoying, and my page got stuck after i fixed it, as everytime
i tried to leave the textbox it caused the key up popup, then when i closed
the popup it causd the key down popup.

Anyway, HTH

"peshrad" <pe*****@Bieber Gruppe.de> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
Hi !

I'm working with Win 2K and Visual Studio 2003.

I have a problem because pressing <ENTER> in a text input control causes a
postback of my web form.
Here comes some example code (already stripped of most of the unnecessary
code):

----------------------------------------------------------------------------
----------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form name="Form1" method="post" action="WebForm 1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMTI3 OTMzNDM4NDs7PmA 5uGMyk9VLm/FRbF5zeYsdMA+5" />

<INPUT onkeydown="aler t('Hi, down !');" onkeyup="alert( 'Hi, up!');">
</form>
</body>
</HTML>
----------------------------------------------------------------------------
----------------------------------------------------------

The postback occurs after the onkeydown event and before the onkeyup
event,
but I don't understand why.

Does anybody know a way of avoiding this undesirable automatic postback ?

Your kind help would be appreciated.

Peter

Nov 19 '05 #2
> take the action of the form:
action="WebForm 1.aspx"
This is whats causing the form to submit.


How can I suppress the "action" argument in the <form> tag of an ASPX page ?
The "action" argument was set by IIS automatically. I hadn't specified any
value for it.
The code in my first posting was code sent by IIS to the browser.
The original ASPX file's content was the following:

----------------------------------------------------------------------------
---------------------------------------------------
<%@ Page language="c#" Codebehind="Web Form1.aspx.cs" AutoEventWireup ="false"
Inherits="TestE nter.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT onkeydown="aler t('Hi, down !');" onkeyup="alert( 'Hi, up!');">
</form>
</body>
</HTML>
----------------------------------------------------------------------------
---------------------------------------------------

Nov 19 '05 #3
thats wierd, doesn't post back for me.

Try attached
"peshrad" <pe*****@Bieber Gruppe.de> wrote in message
news:ul******** ******@TK2MSFTN GP14.phx.gbl...
take the action of the form:
action="WebForm 1.aspx"
This is whats causing the form to submit.


How can I suppress the "action" argument in the <form> tag of an ASPX page
?
The "action" argument was set by IIS automatically. I hadn't specified any
value for it.
The code in my first posting was code sent by IIS to the browser.
The original ASPX file's content was the following:

----------------------------------------------------------------------------
---------------------------------------------------
<%@ Page language="c#" Codebehind="Web Form1.aspx.cs"
AutoEventWireup ="false"
Inherits="TestE nter.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT onkeydown="aler t('Hi, down !');" onkeyup="alert( 'Hi, up!');">
</form>
</body>
</HTML>
----------------------------------------------------------------------------
---------------------------------------------------




Nov 19 '05 #4
Hi,

This behaviour is by design if form contains just one input. See
http://ppewww.ph.gla.ac.uk/~flavell/...mquestion.html
for more information.

Milosz Skalecki
MCP, MCAD

"peshrad" wrote:
Hi !

I'm working with Win 2K and Visual Studio 2003.

I have a problem because pressing <ENTER> in a text input control causes a
postback of my web form.
Here comes some example code (already stripped of most of the unnecessary
code):

----------------------------------------------------------------------------
----------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form name="Form1" method="post" action="WebForm 1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMTI3 OTMzNDM4NDs7PmA 5uGMyk9VLm/FRbF5zeYsdMA+5" />

<INPUT onkeydown="aler t('Hi, down !');" onkeyup="alert( 'Hi, up!');">
</form>
</body>
</HTML>
----------------------------------------------------------------------------
----------------------------------------------------------

The postback occurs after the onkeydown event and before the onkeyup event,
but I don't understand why.

Does anybody know a way of avoiding this undesirable automatic postback ?

Your kind help would be appreciated.

Peter

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
24335
by: Denis Hierstein | last post by:
I need a function, witch make a break in a for-loop and wait for the <enter>-key ... when I use Pascal I just use the Read; or the ReadLn;-function, then the loop stop as long as the user push the <Enter>-key.
2
15692
by: Brett | last post by:
I have a text area form object. A user clicks a send button and the text area information is submitted. How can I also allow the information to be submitted after the user hits the <enter> key? Thanks, Brett
4
1648
by: bh | last post by:
So, I am debating with someone about this. He believe that you can set up so when the user presses Enter it acts just like Tab, so it follows the tab order between text boxes in .NET just like you can do in Access. I personally have never run across something like this, but I am still young in the .NET Programming world so perhaps I just haven't run across it yet. Thanks for the help.
4
3859
by: aurgathor | last post by:
I have a code that reads in 2 shorts, and checks if they are in a given range. I'd like to modify it to use a predefined default value if nothing, but as newline is entered. What would be the best way to do that? TIA current code: do {
7
20368
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common browsers? The script bellow is IE only. It fails FF 1.0 and NN 7. Also, if I can trap the keypress I would like to use it to tab to the next tabindex.
5
2018
by: DotNetGruven | last post by:
Hi, I have a web form which has: - Login area with - email textbox - password textbox - <enter> button to log in - search area with - string to search for textbox
2
1820
by: Rocio | last post by:
I have a aspx page, with 2 controls (ascx). Control1 contains a SEARCH button, and textbox to enter the string to search for. Control 2 contains a LOGIN button, and 2 text boxes to enter the username & password to login. Any user can perform a search, but if he applies for an account, he can login and performed an enhanced search. Currently, the SEARCH button responds when the user clicks <Enter>,
4
4856
by: almurph | last post by:
Hi everyone, I'm a newbie to javascript. I have written some code to detect when a user presses the down-arrow, up-arrow and enter button. Essentially the user can arrow down or up through a list and the textbox is populated with the option when the user presses the enter button. This is for a VB.NET Web form type project. The problem is that when I press the enter button the entire form get
1
2337
by: almurph | last post by:
Hi everyone, I'm a newbie to vb.net. I have written some code to detect when a user presses the down-arrow, up-arrow and enter button. Essentially the user can arrow down or up through a list and the textbox is populated with the option when the user presses the enter button. This
0
9171
Oralloy
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...
0
9032
jinu1996
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...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
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...
0
7743
agi2029
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...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2008
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.