"Undifined" When calling from Client Side

3 posts, 1 answers
  1. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 11 Mar 2009 Link to this post

    Hi, there, Just trying to change item status from Clientside and got an undifined error
    here is my code
    <telerik:RadToolBar ID="ToolListing" runat="server" CssClass="toolbar" OnClientButtonClicking="onToolButtonClick">  
                    <collapseanimation type="None"></collapseanimation> 
                    <items> 
                        <telerik:RadToolBarButton runat="server" CommandName="ALL" Text="All" Value="ALL" 
                            ImageUrl="~/Images/Icons/select_all_new.png" ImagePosition="AboveText" PostBack="False">  
                        </telerik:RadToolBarButton> 
                    </items> 
    </telerik:RadToolBar> 
      <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">  
     
            <script type="text/javascript">  
          <!--  
     function onToolButtonClick(sender, args) {  
                     if (args.get_item().get_commandName() == 'ALL') {  
                        var atoolBar = $find("<%=ToolListing.ClientID %>");  
                        atoolbar.findItemByValue("ALL").set_enabled(false);  
                        args.set_cancel(true);  
                    }  
                }  
                
     -->        
            </script> 
     
        </telerik:RadCodeBlock> 


    Strange it will actually not work
    any idea?
  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 12 Mar 2009 Link to this post

    Hi James Shelton Agar,

    The problem is the incorrect casing of atoolBar (the real object) and atoolbar (undefined).

    You can change it or, even better, to use the sender object.

    You can further optimize the code by using this one:

    function onToolButtonClick(sender, args) { 
         var item = args.get_item();   
         if (item.get_commandName() == 'ALL') {   
            item.set_enabled(false);   
            args.set_cancel(true);   
        }   
    }  

    I hope this helps.

    Greetings,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 12 Mar 2009 Link to this post

    u r absolute right.... oops
Back to Top