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

Default to Cancel with RadConfirm

6 Answers 120 Views
Window
This is a migrated thread and some comments may be shown as answers.
ColinBowern
Top achievements
Rank 1
ColinBowern asked on 02 Apr 2010, 11:19 PM
I was surprised I didn't find anything in the search on this - how would you go about making the Cancel button the default one for a RadConfirm dialog?

6 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 07 Apr 2010, 11:53 AM
Hello ColinBowern,

By design RadWindowManager will always focus the first button in the confirmation dialog. If you want to customize this behavior, you need to implement a custom confirm template. More information on RadWindowManager's templates is available here.

Sincerely yours,
Georgi Tunev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Lee
Top achievements
Rank 1
answered on 12 Jul 2016, 01:16 PM

Georgi,

Can you be more specific as to what needs to be done in the template to change the focus to the cancel button. Also, once this is done, will pressing the spacebar fire the cancel button event?

Lee

0
Marin Bratanov
Telerik team
answered on 13 Jul 2016, 07:50 AM

Hi Lee,

The easiest approach is to use JavaScript to focus the desired button after opening the dialog. Here is an example

var dialog = radconfirm("sure?", callback);
setTimeout(function () {
    //first option is for Classic RenderMode, second is for Lightweight RenderMode
    var cancelBtn = $telerik.$(".rwPopupButton", dialog.get_contentElement()).get(1) || $telerik.$(".rwCancelBtn", dialog.get_contentElement()).get(0);
    if (cancelBtn) {
        cancelBtn.focus();
    }
}, 0);


Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Lee
Top achievements
Rank 1
answered on 13 Jul 2016, 12:53 PM

Unfortunately, I am calling radconfirm from vb.net server side. How do I set default in that case? Here is what I'm doing:

RadWindowManager1.RadConfirm(....)

0
Marin Bratanov
Telerik team
answered on 13 Jul 2016, 01:02 PM

Hi,

You can use the OnClientShow event of the RadWindowManager to execute this code. Just replace the dialog variable with the sender argument: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/events/onclientshow.

Here is an example:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" OnClientShow="OnClientShowHandler" RenderMode="Lightweight"></telerik:RadWindowManager>
<script>
    function OnClientShowHandler(sender, args) {
        setTimeout(function () {
            //first option is for Classic RenderMode, second is for Lightweight RenderMode
            var cancelBtn = $telerik.$(".rwPopupButton", sender.get_contentElement()).get(1) || $telerik.$(".rwCancelBtn", sender.get_contentElement()).get(0);
            if (cancelBtn) {
                cancelBtn.focus();
            }
        }, 0);
    }
    function callback(arg) {
        alert(arg);
    }
</script>

protected void Page_Load(object sender, EventArgs e)
{
    RadWindowManager1.RadConfirm("sure?", "callback", null, null, null, "title");
}


Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Lee
Top achievements
Rank 1
answered on 13 Jul 2016, 02:35 PM
Thank you, Marin. It works perfectly.
Tags
Window
Asked by
ColinBowern
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Lee
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or