473,471 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to link an asp:textbox to an asp:imagebutton in a User Control

Does any body knows how to link an asp:textbox to an asp:imagebutton, both
inside a User Control in asp.net 2 beta 2? So when a user enter some text
in the textbox and press the "Enter" key the corresponding button click
event is launched?
Tnx.
Nov 19 '05 #1
5 1689
Alex,

You can register a java script that looks like below to get what you
need.

TextBox1.Attributes.Add("onkeydown", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.all." + ImageButton.ClientID + ".click();return
false;}else return true;");

You can use the following free control too.
http://www.metabuilders.com/tools/DefaultButtons.aspx

Asp.net 2.0 has the default button property built in.

HTH,
Souri Challa

Nov 19 '05 #2
Hi Souri, I tried that many times before with asp.net 2 beta 2 and it
doesn't work. It worked ok when I used asp.net 1.x. Problem is that asp.net
2 is rendering something like amp&; instead of just & and then the
javascript is not correct. I have tried many different options but none have
worked.
The built in default button property is just for one buton but I have like
five pairs textbox-imagebutton.

thanks,
alex.


"souri challa" <so*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Alex,

You can register a java script that looks like below to get what you
need.

TextBox1.Attributes.Add("onkeydown", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.all." + ImageButton.ClientID + ".click();return
false;}else return true;");

You can use the following free control too.
http://www.metabuilders.com/tools/DefaultButtons.aspx

Asp.net 2.0 has the default button property built in.

HTH,
Souri Challa

Nov 19 '05 #3
Ok. I see what is going on in asp.net 2.
Replacing the above code with below statement will do the trick.

TextBox1.Attributes.Add("onkey*down", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.getElementById(" + ImageButton1.ClientID +
").click();return false;}else return true;");

Reason: Asp.net 2.0 does not render a 'name' tag which is breaking the
above client script that uses document.all syntax. So changing it to
document.getElementById does the job.

-Souri

Nov 19 '05 #4
thanks a lot. I'll try that and I'll let you know.

alex.

"souri challa" <so*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Ok. I see what is going on in asp.net 2.
Replacing the above code with below statement will do the trick.

TextBox1.Attributes.Add("onkey*down", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.getElementById(" + ImageButton1.ClientID +
").click();return false;}else return true;");

Reason: Asp.net 2.0 does not render a 'name' tag which is breaking the
above client script that uses document.all syntax. So changing it to
document.getElementById does the job.

-Souri
Nov 19 '05 #5
It worked just OK. Thanks!
"souri challa" <so*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Ok. I see what is going on in asp.net 2.
Replacing the above code with below statement will do the trick.

TextBox1.Attributes.Add("onkey*down", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){document.getElementById(" + ImageButton1.ClientID +
").click();return false;}else return true;");

Reason: Asp.net 2.0 does not render a 'name' tag which is breaking the
above client script that uses document.all syntax. So changing it to
document.getElementById does the job.

-Souri
Nov 19 '05 #6

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

Similar topics

0
by: Luis Esteban Valencia | last post by:
am trying to databind within an asp:textbox control. I have tried many variations found here but nothing seems to work. It works fine if I use a regular HTML textbox input though. Here is what I...
0
by: Armand | last post by:
Hi All, I have a question about binding datepicker Java Script to asp:textbox control. I recently binded it to html input type=text. Is there a way to bind it to asp:textbox control? Thank...
1
by: rbg.net | last post by:
I know that there is a autocomplete property for the HTML "INPUT type=text" control which if set to OFF, disables autocomplete of the input textbox (doesn't remember previously entered values) ...
1
by: rbg.net | last post by:
I know that there is a autocomplete property for the HTML "INPUT type=text" control which if set to OFF, disables autocomplete of the input textbox (doesn't remember previously entered values) ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...
1
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...
1
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...
0
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...
0
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...

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.