Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

ToolBar / Docking ToolBar

     
 
  • New Document
  • Open
  • Save
  • Print
  • Cut
  • Copy
  • Paste
  • Undo
  • Redo
  • Align Left
  • Justify
 
     

  • The Client-Side API of RadToolBar and RadDock allows the controls to seamlessly interact with each other.

    This example shows how to use RadToolBar in a RadDock and change the toolbar's orientation depending on the parent zone.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Controls.Integration.DockingToolBars.DefaultCS" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1" />
        
        <link rel="stylesheet" type="text/css" href="Styles/Styles.css" />
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
            <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#" ShowSkinChooser="false" />
            
            <telerik:RadScriptManager ID="ScriptManager" runat="server" />
            
            <telerik:RadDockLayout ID="RadDockLayoutMain" runat="server">
                <div class="main qsfClear">
                    <telerik:RadDockZone
                            id="dockTop"
                            runat="server"
                            Orientation="Horizontal"
                            CssClass="zone horizontalZone"
                            Width="682px"
                            Height="39px" />
                            
                    <telerik:RadDockZone
                            id="dockLeft"
                            runat="server"
                            CssClass="zone verticalZone"
                            Orientation="Vertical"
                            height="355px"
                            width="34px" />
                </div>
                <telerik:RadDock Left="700" Top="220" ID="RadDock1" runat="server" Width="324px" DockHandle="Grip" OnClientDockPositionChanged="clientDockPositionChanged">
                    <ContentTemplate>
                        <telerik:RadToolBar runat="server" id="RadToolBar1" skin="Office2007">
                            <items>
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/New.gif" Tooltip="New Document" CommandName="new" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Open.gif" Tooltip="Open" CommandName="open" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Save.gif" Tooltip="Save" CommandName="save" />
                                <telerik:RadToolBarButton iSSeparator="true" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Print.gif" Tooltip="Print" CommandName="print" />
                                <telerik:RadToolBarButton IsSeparator="true"/>
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Cut.gif" Tooltip="Cut" CommandName="cut" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Copy.gif" Tooltip="Copy" CommandName="copy" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Paste.gif" Tooltip="Paste" CommandName="paste" />
                                <telerik:RadToolBarButton IsSeparator="true" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Undo.gif" Tooltip="Undo" CommandName="undo" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Redo.gif" Tooltip="Redo" CommandName="redo" />
                                <telerik:RadToolBarButton IsSeparator="true" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/AlignLeft.gif" CheckOnClick="true" Group="alignment" Tooltip="Align Left" CommandName="left" />
                                <telerik:RadToolBarButton ImageUrl="~/ToolBar/Examples/ApplicationScenarios/DockingToolBars/Img/Justify.gif" CheckOnClick="true" Group="alignment" Tooltip="Justify" CommandName="justify" Checked="true" />
                            </items>
                        </telerik:RadToolBar>
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockLayout>
            
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                <script type="text/javascript">
                    function clientDockPositionChanged(sender, args)
                    {
                        var dock = sender;
                        var zone = dock.get_parent();
                        var toolBar = $find('<%= RadDock1.ContentContainer.FindControl("RadToolBar1").ClientID %>');
                        
                        if (zone)
                        {
                            if (!zone.get_isHorizontal())
                            {
                                toolBar.set_orientation(Telerik.Web.UI.Orientation.Vertical);
                            }
                            else
                            {
                                toolBar.set_orientation(Telerik.Web.UI.Orientation.Horizontal);
                            }
                        }
                        else
                        {
                            toolBar.set_orientation(Telerik.Web.UI.Orientation.Horizontal);
                        }
                        
                        var dockContentArea = toolBar.get_element().parentNode;
                        if (dockContentArea.style.height != "auto")
                        {
                            dockContentArea.style.height = "auto";
                        }

                        if (toolBar.get_orientation() === Telerik.Web.UI.Orientation.Horizontal)
                        {
                            dock.get_element().style.width = "324px";
                            dock.get_element().style.height = "39px";
                        }
                        else
                        {
                            dock.get_element().style.width = "34px";
                            dock.get_element().style.height = "322px";
                        }
                    }
                </script>
            </telerik:RadCodeBlock>
            
            <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451