Conflict event handling.

Z

zlf

Hello
Currently, I'm using javascript to respond the "ENTER" button press event in
my ASPNET page.
It works fine when there is no multi-line textbox, but when multi-line
textbox is presented in page, and user enters "ENTER" button, both of my
javascript and textbox responses it.
It is unexpected. How can I ask my javascript to ignore it in this case or
ask TextBox to accept ctrl+enter as "ENTER".

<script type="text/javascript">
function keyDown()
{
var keycode=event.keyCode;
if(keycode==13){
event.keyCode=65;
__doPostBack('ctl00$ctl00$SsnContentPlaceHolder$SearchButton','');
}
}
document.onkeydown=keyDown;
</script>

Thanks
 
Z

zlf

It works!
Thank you!

Eliyahu Goldin said:
Instead of handling onkeydown event for document, do it for the textbox:

myTextbox.Arrtibutes["onkeydown"] = "keyDown()";

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


zlf said:
Hello
Currently, I'm using javascript to respond the "ENTER" button press event
in my ASPNET page.
It works fine when there is no multi-line textbox, but when multi-line
textbox is presented in page, and user enters "ENTER" button, both of my
javascript and textbox responses it.
It is unexpected. How can I ask my javascript to ignore it in this case
or ask TextBox to accept ctrl+enter as "ENTER".

<script type="text/javascript">
function keyDown()
{
var keycode=event.keyCode;
if(keycode==13){
event.keyCode=65;

__doPostBack('ctl00$ctl00$SsnContentPlaceHolder$SearchButton','');
}
}
document.onkeydown=keyDown;
</script>

Thanks
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top