Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > JS: How to disable all?

Not answered JS: How to disable all?

Feed from this thread
  • Runat="Server" avatar

    Posted on Nov 8, 2011 (permalink)

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

    Thanks.

    Reply

  • Posted on Nov 9, 2011 (permalink)

    Hello Runat="Server",

    You can try the following javascript.
    JS:
    <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);
           itm.set_enabled(false);
         }
     }
    </script>

    Thanks,
    Princy.

    Reply

  • Runat="Server" avatar

    Posted on Nov 9, 2011 (permalink)

    Hello,

    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) .

    Problem!

    Reply

  • Kate Kate admin's avatar

    Posted on Nov 14, 2011 (permalink)

    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
        alert(button);
        var button1 = $telerik.findElement(tbutton.get_element(), ("btn"));
               //to find a generic HTML element
        alert(button1);
    }

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

    All the best,
    Kate
    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > JS: How to disable all?
Related resources for "JS: How to disable all?"

[   ASP.NET ToolBar Features  |  Documentation  |  Demos  |  Telerik TV   |   Self-Paced Trainer   |  Step-by-step Tutorial  ]