JS: How to disable all?

4 posts, 0 answers
  1. Runat="Server"
    Runat="Server" avatar
    14 posts
    Member since:
    Feb 2010

    Posted 08 Nov 2011 Link to this post

    How to disable all items of ToolBar in client side include separators, templates and buttons ets?

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Nov 2011 Link to this post

    Hello Runat="Server",

    You can try the following javascript.
    <script type="text/javascript">
    function OnClientClick()
        var toolBar = $find("<%= RadToolBar1.ClientID %>");
        var items = toolBar.get_items();
        for (var i = 0; i < items.get_count(); i++)
           var itm=  items.getItem(i);

  3. DevCraft R3 2016 release webinar banner
  4. Runat="Server"
    Runat="Server" avatar
    14 posts
    Member since:
    Feb 2010

    Posted 09 Nov 2011 Link to this post


    This only works for simple buttons.

    If we use a <ItemTemplate> with an internal RadMenu with sub RadMenu
    or code HTML inside <ItemTemplate>, nothing happens!

    The content of ToolBar is generated dynamically. So, find all itemtemplates and buttons one-by-one for disable/enable - the bad way!

    I need to block all the tools, if user is out of system. After login must to enable toolbar. When user is log out, then change toolBar to disable mode  ( switch - enable/disable) .

  5. Kate
    Kate avatar
    1898 posts

    Posted 14 Nov 2011 Link to this post

    Hello Arie,

    Besides the approach that Princy has suggested you will also need to find the different controls in the RadToolbar and disable them as well.  You can use the following code for instance:
    function OnClientLoad() {
        var toolBar = $find("<%= toolbar1.ClientID %>"); 
        var tbutton = toolBar.findItemByValue("value1")
        var button = tbutton.findControl("Button1"); //for RadControls
        var button1 = $telerik.findElement(tbutton.get_element(), ("btn"));
               //to find a generic HTML element

    <telerik:RadToolBar ID="toolbar1" AutoPostBack="true" Width="100%" runat="server"
                OnClientLoad="OnClientLoad" >
                <telerik:RadToolBarButton Text="LeaveButton" Value="leaveButton1">
                    <telerik:RadToolBarButton Value="value1">
                            <telerik:RadButton ID="Button1" runat="server" Text="Button" />
                            <asp:Button ID="btn" Text="Leave" runat="server" />

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top