This is a migrated thread and some comments may be shown as answers.

Enter Key causes PostBack in Edit Mode

3 Answers 436 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Landon
Top achievements
Rank 2
Landon asked on 15 Feb 2011, 12:22 AM
Hi there,

Is there a way to DISABLE the Enter Key's functionality while in Edit/Insert Mode? I have tried a couple different Java functions and also played with the "AllowKeyboardNavigation" Client Setting on the grid but have had no luck.

Currently the problem only occurs only while in Edit/Insert Mode, and causes Clients to lose information entered in the Edit/Insert Form if they accidentally hit the enter key.

Any Ideas?

Regards,

Landon

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Feb 2011, 11:05 AM
Hello Landon,

You can attach OnKeyPress client event  to caprture the Enter key press and prevent the PostBack on clicking the Enter key.

ASPX:
<ClientSettings  >
     <ClientEvents  OnKeyPress="KeyPress" />
</ClientSettings>

Java Script:
<script type="text/javascript" >
 function KeyPress(ctrl, e)
 {
   
  if (e.get_domEvent().rawEvent.keyCode == 13) 
   {  
    e.get_domEvent().preventDefault()  
    e.get_domEvent().stopPropagation()  
   }       
 }
</script>

Another suggestion, you can find here:
On Edit mode if i pressed enter page get refresh

Thanks,
Princy.
0
Princy
Top achievements
Rank 2
answered on 15 Feb 2011, 11:06 AM
 
0
Landon
Top achievements
Rank 2
answered on 15 Feb 2011, 04:24 PM
That worked perfect, thanks!
Tags
Grid
Asked by
Landon
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Landon
Top achievements
Rank 2
Share this question
or