Friday, May 11, 2012

How to block the execution thread using RadConfirm

Finally found a way to use the RadConfirm popup, which is invoked from client side, in combination with server side events. Following example will display the confirmation window and only continues to call the button click event IF the OK button is clicked by the user.


<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">

        var lastClickedItem = null;
        var clickCalledAfterRadprompt = false;
        var clickCalledAfterRadconfirm = false;

        function onClientButtonClicking(sender, args) {
            if (args.get_item().get_text() == "Order another beer") {
                if (!clickCalledAfterRadconfirm) {
                    lastClickedItem = args.get_item();
                    radconfirm("Are you sure? You order it, you finish it!", confirmCallbackFunction);

        function confirmCallbackFunction(args) {
            if (args) {
                clickCalledAfterRadconfirm = true;
            clickCalledAfterRadconfirm = false;
            lastClickedItem = null;


    <telerik:RadToolBar ID="RadToolBar1" runat="server" OnClientButtonClicking="onClientButtonClicking" OnButtonClick="RadToolBar1_ButtonClick" Width="100%">
        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                <telerik:RadToolBarButton CommandName="OrderBeer" runat="server" Text="Order another beer"></telerik:RadToolBarButton> 

The CommandItemTemplate part you obviously need to add to your MasterTableView element..


protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        RadToolBarButton button = e.Item as RadToolBarButton;
        if (button.CommandName == "OrderBeer")
            \\Do stuff, drink the beer

Have a nice weekend folks!!!


  1. Hello thanks for the post, now I got some real light in this ...but, I tried to do the sames with a asp button and dont work the same way of the radtoolbar. any thoughts?

  2. Hi Davey,

    For an ordinary asp button things are a lot easier.

    1. Create a javascript function which returns a boolean, for example:

    function ConfirmOrder()
    // your business logics.. or really simple example:
    return confirm("Do you really want to order?");

    2. Add the function call to the OnClientClick of your button:

    So, if the 'confirm' function returns 'false', the server side method 'btnOrder_Click' will not be executed.