Cancel Close event client side

3 posts, 1 answers
  1. Dave
    Dave avatar
    4 posts
    Member since:
    Oct 2013

    Posted 15 Nov 2013 Link to this post

    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.


    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. Answer
    Slav avatar
    1359 posts

    Posted 20 Nov 2013 Link to this post

    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.

    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.
  3. Dave
    Dave avatar
    4 posts
    Member since:
    Oct 2013

    Posted 22 Nov 2013 Link to this post

    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.
Back to Top