473,395 Members | 1,790 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,395 software developers and data experts.

fire an image button click event using javascript

..Hi all,

I want to catch an 'enter' keypress event on a web form and submit the form
as if a button had been clicked rather than the default post back behaviour.
I know the following javascript can be placed in the body tag to do this.

onkeydown="if(event.keyCode ==
13){document.getElementById('iBtnSubmit').onClick( );

This will work fine if 'iBtnSubmit' is an input type of 'Button' but the
problem I am having is that the button in question is an image button. This
is rendered by the server as an input type of 'image' which does not have a
click method. Does anyone have any idea of how I can recreate this behaviour
for an imagebutton?

Thanks, Andy
Nov 19 '05 #1
1 10791
Found a solution to this if anyone is interested. Instead of trying to fire a
click event set the focus on to the image button. This will then fire the
click event when the postback takes place. Again place this in the opening
<body> tag.

onkeydown="if((event.which ? event.which : event.keyCode) ==
13){document.getElementById('iBtnSubmit').focus(); "

Nov 19 '05 #2

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

Similar topics

2
by: ron | last post by:
hi, I have two image buttons for a custom paging solution in a DataGrid, I would like both button's to use the same Click Event. I have seen this done before but can not remember were, would some...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
1
by: Roger | last post by:
Have a grid and when I edit a grid row it goes into edit mode. Once I attempt to click a button on the form; once the grid losses focus, it fires my beforerowupdate event. Runs through my code, but...
3
by: Steve Kershaw | last post by:
Hi, I need to fire a server side button click event from my client side javascript. The client side javascript code follows: <script language="javascript" type="text/javascript"> function...
17
by: Eric | last post by:
I'm new to JavaScript and I wrote this code to play with. Oddly, if I enter text in a box and then press the button, I only get the onChange event for the text box and not the button's onclick...
2
by: Sunny | last post by:
Hi, I have an application using IE6 before and now we have upgraded to IE7. After upgrading, I have been having issues with button click event when embedded JavaScript file into the page....
0
by: nraji | last post by:
hi, I have designed a web part using VS 2003 (Web control library template). I need to publish that in share point. Its not like drag and drop the things from toolbar. Every thing I need to do in...
4
yarbrough40
by: yarbrough40 | last post by:
can any one tell me if there is a way to pass a string variable to a button click event? ultimately I am looking to fire client side Javascript "__doPostBack('Button1','click','')" and have the...
2
Prakash Gnana
by: Prakash Gnana | last post by:
Please help me to get the answer.. Thanks..
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
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,...
0
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...
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...

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.