473,587 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(e vent.keyCode ==
13){document.ge tElementById('i BtnSubmit').onC lick();

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 10811
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.ge tElementById('i BtnSubmit').foc us();"

Nov 19 '05 #2

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

Similar topics

2
3343
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 please give brief explanation of how? Thanks Ron
4
4016
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 ontop of the webform1: Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code "
1
1640
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 never fires the button click event. If I do not change anything on the grid, it does fire the button click event. Any ideas.
3
52212
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 myFunction() { var strname; strname = prompt("What is your name", "");
17
9637
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 event. But if I press the button without entering text first, the button click event does work. What's up? <html> <body> <h3>Events on Buttons and...
2
1353
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. Removing the embeded java scrip file makes my button fire the click event again. Does anyone has the same problem? If so, what is the solution for it? ...
0
2027
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 code behind side. I have a button and text box Button Id: btnSearch TextBox id: txtSearch
4
7019
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 server-side button event retrieve the string I have set. for example: in Javascript - I have set this string variable --> '123456' I call a do...
2
2424
Prakash Gnana
by: Prakash Gnana | last post by:
Please help me to get the answer.. Thanks..
0
8349
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...
1
7974
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...
0
8221
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...
0
6629
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...
1
5719
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...
0
5395
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...
0
3845
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...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1192
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...

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.