473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

<ENTER> causes ImageButton to fire! (weird)

I'm using VS 2005 to develop an intranet asp.net web application and I get a
weird situation. If I start out with any ASPX page that contains an
ImageButton control followed by a TextBox control, everything works okay. I
can press <ENTER> when the cursor is inside the text box and the page is
running, and no events fire (this is what I expect). But as soon as I drop a
second text box on the page (ie: after th first one) then pressing <ENTER>
in the first text box while running causes the ImageButton1_Click to fire
(even though I'm not actually clicking on the ImageButton control!!!).

I've included a very simple test program below that illustrates the problem.

This is a big problem because I want to have many ImageButton and TextBox
controls on the same ASPX page, and I also do not want the ImageButton Click
event to fire when the user simply presses <ENTER> in a text box. If the
user presses <ENTER> in a text box, or types in data and then presses
<ENTER>, it does the application no good to start firing off Click events
from some unrelated control. In my case it makes my calendar expand out of
nowhere on the page (because the ImageButton control in my case is a "+"
tree expander that is intended to expand or hide the calendar).

What causes this behaviour and how can I fix it?

Thanks,

Tom Edelbrok

Here is the ASPX page (and at the bottom of the post is the Code-Behind VB
stuff):

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Main.aspx.vb"
Inherits="main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:ImageButton ID="ImageButton1" runat="server" />

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:Button ID="Button1" runat="server" Text="Button" />

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />

<br />

<br />

<br />

<br />

</div>

</form>

</body>

</html>

HERE IS THE CODE-BEHIND VB STUFF:

Partial Class Main

Inherits System.Web.UI.Page

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

Response.Write("ImageButton1_Click firing")

End Sub

End Class
May 18 '06 #1
0 1803

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

Similar topics

11
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...
7
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...
7
by: Susan Bricker | last post by:
I know that I saw some information concerning the <shift>+<enter> combination use to bypass launching an Access mdb application and enter the Access design workspace. Would someone please direct...
6
by: tor | last post by:
Hello How can I use an other key then TAB to move from one textBox to another?? Torfinn
0
by: VMI | last post by:
If I'm in a multi-line textbox and I'm writing a postal address (ie. write ist line and press <Enter>, write 2nd line and press <Enter>, etc...) how can I make sure that the Enter key will always...
2
by: JP | last post by:
Hi, It's a login screen, so users enter their ID/Password and hit <ENTER> instead of clicking on Login button. But when they hit <ENTER> an Image Button gets clicked. I want to make my Login...
2
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...
4
by: Paul W | last post by:
On my simple login-screen I have a 'username' and 'password' field and an imagebutton for the 'OK'. This used to work nicely so that when the user hit <Enter> from the password field, it invoked...
4
by: peshrad | last post by:
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...
2
by: Stevecbl | last post by:
Hello, I have an application that works on a PPC 2003 device but causes a slight problem on a WM 5.0 device. These devices are equipt with barcode scanners. The problem that I am seeing is that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
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...

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.