Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Toolbar > Delete confirmation from Rad Toolbar
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Delete confirmation from Rad Toolbar

Feed from this thread
  • Stacy avatar

    Posted on Apr 19, 2011 (permalink)

    I have been thru these forums a lot and still haven't found a proper solution to show a delete confirmation from a RadToolbar.  Do you have an example that works?

    I have a toolbar with two buttons, "Add", "Delete".

    I can get my javascript confirmation to load but even if it returns false, my "EmployeeSummaryToolBar_ButtonClick" event fires off and executes the delete code.

    Any help would be appreciated.

    -------------------------------------------------------------------------------------------------------
    Add to toolbar "OnClientButtonClicking="confirmation"

    Javascript:

     

     

    function confirmation(sender, args) {

     

     

     

     

    var button = args.get_item();

     

     

     

     

    if (button.get_commandName() == "Delete") {

     

     

     

     

    var message = "blah blah";

     

     

    args.set_cancel(!confirm(message));

     

    }

     

    }

     

    in c# file..

     

     

     

     

     


    protected
    void ToolBar_ButtonClick(object sender, RadToolBarEventArgs e)

     

     

    {

     

     

     

     

    String commandName = ((RadToolBarButton)e.Item).CommandName.ToLower();

     

     

     

     

     

    if (commandName.Equals("delete"))

     

     

    {

     

        Deletefunction(your_args);

     

    }

     

    }

  • Kate Kate admin's avatar

    Posted on Apr 21, 2011 (permalink)

    Hello Stacy,

    You could easily achieve this by using client side method OnClientButtonClicking. You can read more about it here. I also attached a sample project demonstrating how it works. Here is the Javascript method and how you attach the event handler:
    function onClientButtonClicking(sender, args) {
               var toolBar = $find("<%=RadToolBar.ClientID %>");
               var button = toolBar.findItemByText("Button 0");
               var agree = confirm("Are you sure you want to delete?");
               if (agree)
                   return true;
               else
                   return args.set_cancel(true);
     
           }

    <telerik:RadToolBar ID="RadToolBar" runat="server" OnClientButtonClicking="onClientButtonClicking" OnButtonClick="RadToolBar_ButtonClick" >
     <Items>
                    <telerik:RadToolBarButton runat="server" Text="Button 0" >
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton runat="server" Text="Button 1">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton runat="server" Text="Button 2">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton runat="server" Text="Button 3">
                    </telerik:RadToolBarButton>
                    
                </Items>
            </telerik:RadToolBar>


    Greetings,
    Kate
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Toolbar > Delete confirmation from Rad Toolbar