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

Cancel Close event client side

2 Answers 110 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 15 Nov 2013, 06:15 PM
Hi I am using the raddock and when a user clicks the close button it fires a server side method which marks the selected raddock item as deleted. Thing is I want to ask the ask if they are sure before doing so.

I wrote this piece the js below which fire ok but the server side event is hit whether the user selects yes or no.

Any help would be appreciated.

Thanks,

Dave J.

function OnClientCommand(sender, args) {
    if(args.Command.get_name() == "Close")
    {
       var r = confirm("Are you sure you want to delete this Form Field?");
       if (r == true) {
          return true;
       }
       else {
          return false;
       }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 20 Nov 2013, 03:26 PM
Hello Dave,

The OnClientCommand event exposes a function set_cancel that lets you prevent the command from raising any additional events, however it is not applicable for the built-in command, one of which is Close.

Nevertheless, you can configure a custom dock command that will have the same functionality as the Close command and it will be possible to cancel it when needed. I have attached a sample page that demonstrates this approach. Please use it as a reference for incorporating the desired functionality into your actual project.

Regards,
Slav
Telerik
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 the blog feed now.
0
Dave
Top achievements
Rank 1
answered on 22 Nov 2013, 11:40 AM
Hi Slav,

Many thanks for your detailed and helpful reply. What I ended up doing was putting the users confirmation of removing the item into a hidden field and the server event look at this field and if the user selected not to remove it the code does something like raddock.Closed = False

But I like your way also.

Cheers, Dave.
Tags
Dock
Asked by
Dave
Top achievements
Rank 1
Answers by
Slav
Telerik team
Dave
Top achievements
Rank 1
Share this question
or