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

.click causes Stack overflow

1 Answer 42 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Pei Chen
Top achievements
Rank 1
Pei Chen asked on 11 Jan 2010, 09:50 PM

When user clicking "view" on the radContextMenu, btn.click(); repeats itself over and over again until it throws an Stack Overflow error.  Can someone please point me a workaround?  Thank you!!

hours ago (permalink)   
 
 
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>    
 

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 12 Jan 2010, 02:14 PM
Hi Pei Chen,

Calling the btn.click() will fire again the OnClientButtonClicking event hence the problem.
I suggest that you remove that line from your javascript code (OnToolBarButtonClicked method) since it is not needed.

Best wishes,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ToolBar
Asked by
Pei Chen
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or