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

Set focus on Cancel button when radConfirm is called

4 Answers 448 Views
Window
This is a migrated thread and some comments may be shown as answers.
Nainil
Top achievements
Rank 1
Nainil asked on 03 Nov 2011, 05:18 PM
I am simply calling radConfirm which opens up the default "OK" and "Cancel" buttons. However the "Cancel" button does not have focus.
   Is there a property or client side code that can set focus on "Cancel" button

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Nov 2011, 03:18 PM
Hi Nainil,

By default the OK button is closed as this is the behavior of the browser confirm dialog. Therefore there is no simple property to change it. You can, however, use some JavaScript to focus the element you wish:
var oConfirm = radconfirm("sure?", alertUserResponse);//gets a reference to the confirm popup
var elementList = $telerik.$(".rwPopupButton", oConfirm.get_popupElement());//gets reference to the buttons in the confirm
setTimeout(function ()
{
    elementList[1].focus();//focuses the second button, which is the cancel
}, 0);

I am also attaching a simple page that shows this in action.

Kind regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Nainil
Top achievements
Rank 1
answered on 07 Nov 2011, 03:04 PM
Marin,
    Thanks for the response. That does help. However when the confirm window comes up with the Cancel button having focus, if I tab out using the tab key, I can keep on tabbing to go through few of the IE's input controls (such as back, and forward buttons, url textBox, etc) and eventually, the focus comes back to the form on which the confirm window is still visible. Suppose I have a logout link at the top of my page, then on tabbing a few times, the logout link will gain focus and I can logout without even hitting the Cancel button.
    Is there any setting to prevent the parent form stealing focus when tabbing after the confirm button is opened, but before any action such as "Cancel" or "OK" have been performed?
       Thanks.
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2011, 07:34 AM
Hello Nainil,

Check the following forum thread which discuss the same.
Tabbing between Ok and Cancel buttons on RadConfirm window

Thanks,
Princy.
0
Marin Bratanov
Telerik team
answered on 08 Nov 2011, 10:06 AM
Hello guys,

Let me point out that currently a modal RadWindow (which is what the RadConfirm is) changes the tabIndex property of all input elements and other elements for which it is relevant to -1 when it is shown. This means that you cannot tab to the page as you can see in the video I recorded: http://screencast.com/t/tL9jUpuhdlut. I used the previously attached page as basis and simply added a textbox that alerts when it gets focus.

It is also important to note that if you expect the keyboard to be used as a navigation tool you would need to prepare your page accordingly - i.e. set tabIndex and accessKey properties where needed. TabIndex is needed for all elements that trigger action when clicked - such as buttons, anchors, inputs, etc, accessKey usage is a developer decision. If a page is not properly configured for keyboard support some unexpected behavior may arise for which we cannot take care of as this is an invalid scenario.


All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Window
Asked by
Nainil
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Nainil
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or