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

[Solved] Hit Enter key clears all data in Radgrid

2 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ying
Top achievements
Rank 1
Ying asked on 24 Jun 2009, 07:19 PM
I have a Radgrid with EditMode="EditForms". When adding a new record, I accidently hit the Enter key and it cleared all data I entered. What event get fired by clicking on Enter key and how to prevent this from happening?

I also tried in editing and noticed that clicking on Enter key make the screen reload the data. All updates are gone.

Does anyone come cross this kind of problem?

Thanks!
Ying

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2009, 04:51 AM
Hi Ying,

You may use the OnKeyPress client event  to caprture the Enter key press. Try the following approach to prevent the PostBack on clicking the Enter key.

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

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


Thanks
Shinu.
0
Ying
Top achievements
Rank 1
answered on 25 Jun 2009, 05:28 PM
Shinu,

Thank you for the reply and it worked!

Ying
Tags
Grid
Asked by
Ying
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ying
Top achievements
Rank 1
Share this question
or