enter key to call <asp:imagebutton> event

R

Randy

I'd like to trap the keypress event for the enter key and trigger a server
side imagebutton click event.

However,

Page.RegisterHiddenField( "__EVENTTARGET", btnSubmitTracking.ClientID );

I've also tried,

txtTrackingNumber.Attributes.Add("onKeyPress", String.Format( "if
(event.keyCode == 13) __doPostBack('{0}', 'parms')",
btnSubmitTracking.ClientID));

This doesn't work with imagebuttons. It works fine with linkbuttons and
buttons, but I need to use an image for a button. Or is there someother
control or way I can accomplish this.

-Randy
 
A

Alessandro Zifiglio

try nesting your image control in a hyperlink control --that should make the
image clickable.
<asp:hyperlink ...onkeypress="bla"><asp:image ...></asp:image></hyperlink>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top