.click error with radconfirm

4 posts, 1 answers
  1. Pei Chen
    Pei Chen avatar
    12 posts
    Member since:
    Jan 2010

    Posted 06 Jan 2010 Link to this post

    I have a radToolBar that I want to show radconfirm when toolbar buttons click, once confirmed, post back to server and execute a function there. 

     

     

    function OnToolBarButtonClicked(sender, args) {

     

    args.set_cancel(

    true);

     

    counter = counter + 1;

    alert(counter);

     

    stopTimer();

    btn = args.get_item();

    bar = sender;

     

     

     

     

    if (btn.get_commandName() == 'Delete') {

     

    document.getElementById(

    "actionButtonIndex").value = 0

     

    radconfirm(

    'Are you sure you want to delete the job(s) permanently?', CallBackFn, 330, 100, '', 'Delete Job');

     

     

        }

    }

     

     

    function CallBackFn(args) {

     

     

    var ToolBar = $find("<%= RadToolBar1.ClientID %>");

     

     

     

    if (args == true) {

     

    btn.click();

     

        }

     

    }

     

     

    <

     

    telerik:RadToolBar ID="RadToolBar1" runat="server" style="display:block; float:none" Skin="Vista" OnClientButtonClicking="OnToolBarButtonClicked" OnButtonClick="ExecPostBackClick">

     

     

     

    <Items>

     

     

    <telerik:RadToolBarButton runat="server" ImageUrl="Style/Images/menudelete.gif" CommandName="Delete" ToolTip="Delete" />

     

    <

     

    telerik:RadToolBarButton runat="server" ImageUrl="style/images/menuEnable.gif" CommandName="Enable" ToolTip="Enable" />

     

     

    <telerik:RadToolBarButton runat="server" ImageUrl="style/images/menuDisable.gif" CommandName="Disable" ToolTip="Disable" />

     

     

    </Items> 

     

     

     

    </telerik:RadToolBar>

    I noticed that the btn.click doesn't do anything.  It doesn't seem like it posts back to the server either.  I added a counter to debug and found out that btn.click hit OnClientButtonClick instead of server's OnButtonClick.  Is there a workaround that you can provide to me or point me out a better way to code what I want to do.  Thanks yoU!  

     

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jan 2010 Link to this post

    Hello,

    Try the following code snippet and see whether it helps.

    JavaScript:
     
        var check = true
        function OnClientButtonClicking(sender, args) { 
            if (check) { 
                args.set_cancel(true); 
            } 
            btn = args.get_item(); 
            bar = sender; 
            if (btn.get_commandName() == 'Delete' && check) { 
                radconfirm('Are you sure you want to delete the job(s) permanently?', CallBackFn, 330, 100, '''Delete Job'); 
            } 
        } 
        function CallBackFn(args) { 
            var ToolBar = $find("<%= reportToolBar.ClientID %>"); 
            if (args == true) { 
                check = false
                btn.click(); 
            } 
        } 
    Attach OnClientButtonClicking event to RadToolBar.

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pei Chen
    Pei Chen avatar
    12 posts
    Member since:
    Jan 2010

    Posted 06 Jan 2010 Link to this post

    Hi Shinu, that worked out beautifully!!!  You're a genius!  Thank you soooooooooooo much!!!!!   :)
  5. Pei Chen
    Pei Chen avatar
    12 posts
    Member since:
    Jan 2010

    Posted 11 Jan 2010 Link to this post


    var check = true;  
     
    function OnToolBarButtonClicked(sender, args) {   
    var selectedRows = $find("<%= rg1.ClientID %>").get_masterTableView().get_selectedItems();  
     
             if (selectedRows.length > 0) {          
                     if (check) {  
                         args.set_cancel(true);  
                     }  
     
                     btn = args.get_item();  
     
                     if (btn.get_commandName() == 'View' && check) {  
     
                            btn.click();  
                            check = false;  
                     }  
                     
             }  
         }  
     
     
         function CallBackFn(args) {  
             if (args == true) {  
                    btn.click();  
         
               
            }  
        }  
     
    '============ Code Behind ======================================  
     
    Public Sub OnMenuPostBackClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs)  
     
    Case "View"  
     
                    For Each item In rg1.MasterTableView.Items  
                        If item.Selected = True Then  
     
                            jobNm = item.GetDataKeyValue("JobName").ToString()  
     
     
                        End If  
     
                    Next  
     
                    
            End Select  
     
    End Sub  
     
    '=====================  ASPX ============================  
     
    <telerik:RadToolBar ID="RadToolBar1" runat="server" style="display:block; float:none" Skin="Vista" OnClientButtonClicking="OnToolBarButtonClicked"  OnButtonClick="ExecPostBackClick">   
          
            <Items> 
                   
                 <telerik:RadToolBarButton runat="server" ImageUrl="style/images/window_view.gif"  CommandName="View" ToolTip="View" />        
            </Items> 
                  
        </telerik:RadToolBar> 

    Maybe not so beautifully...
    It worked as it supposed to with check toggling.  but when it hits btn.click(); it gives "Stack overflow at line: 99".  Any ideas?
Back to Top