PC Review


Reply
Thread Tools Rate Thread

Conflict event handling.

 
 
zlf
Guest
Posts: n/a
 
      12th Mar 2008
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


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12th Mar 2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
zlf
Guest
Posts: n/a
 
      12th Mar 2008
It works!
Thank you!

"Eliyahu Goldin" <(E-Mail Removed)> 写入消息新闻:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Handling Vish Microsoft Access VBA Modules 1 15th Sep 2008 01:39 PM
Handling a C# event from VB.NET Dave Microsoft C# .NET 3 29th Nov 2005 02:50 PM
Custom Event handling + thread handling. Michael McCarthy Microsoft C# .NET 1 14th Jun 2005 02:50 AM
Event handling =?Utf-8?B?RGF2ZQ==?= Microsoft ASP .NET 1 27th Feb 2004 06:31 AM
Handling an Event Sean Microsoft VB .NET 3 14th Jan 2004 04:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:03 AM.