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

can't click on the button by using enter key

2 Answers 81 Views
Input
This is a migrated thread and some comments may be shown as answers.
TelerikUser
Top achievements
Rank 1
TelerikUser asked on 25 Sep 2009, 02:44 AM
I'm using a radformdecorator for a simple login form and for some reason I can't use the Enter key to click on the button and login. Every time I have to use the mouse but many people for convenience use the "enter" button.
How can I fix it?
Thank you!

2 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 28 Sep 2009, 12:37 PM
Hi Florin,

To use Enter key to click as a button, the button should be set as default button of the form.

This can be done in the code behind for example:
            Button button = //find the button      
            form1.DefaultButton = button.UniqueID; 
If you have ajaxified your page you should also use the following code:
Code behind:
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "scr", String.Format("defaultButton='{0}'", button.ClientID), true); 
Javascript:
           var defaultButton; 
           function pageLoad() { 
               
               if (defaultButton) { 
                    
                   document.forms[0].onkeypress = function(e) { 
                       e = e || window.event; 
                       WebForm_FireDefaultButton(e, defaultButton); 
                   } 
               } 
           } 

I hope this will help you.

All the best,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
TelerikUser
Top achievements
Rank 1
answered on 01 Oct 2009, 07:38 PM
The code was ajaxified so the last two blocks of code worked for me. Thank you very much!
Tags
Input
Asked by
TelerikUser
Top achievements
Rank 1
Answers by
Mira
Telerik team
TelerikUser
Top achievements
Rank 1
Share this question
or