Microsoft.SharePoint.WebCon ...


ToolBar Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public MustInherit Class ToolBar
    Inherits UserControl
Visual Basic (Usage)
Dim instance As ToolBar
C#
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public abstract class ToolBar : UserControl
Inheritance Hierarchy

System.Object
   System.Web.UI.Control
     System.Web.UI.TemplateControl
       System.Web.UI.UserControl
        Microsoft.SharePoint.WebControls.ToolBar
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Tags :


Community Content

Reza Alirezaei - MVP
Programmatically adding a toolbar to the top of the webpart chrome

A web part that has its own toolbar with different controls added to it programmatically is easy to build. For more information See http://blogs.devhorizon.com/reza/?p=491

Reza Alirezaei,MVP
Blog: http://blogs.devhorizon.com/reza


Content Master Ltd
ToolBar

Description

The ToolBar class displays a toolbar on a Web Part or other control. You can add controls to the toolbar programmatically, or optionally provide a template for the toolbar which contains the controls that you require.

Usage Scenarios

You will typically use the ToolBar class to add a toolbar to a Web Part. You add buttons and other controls to the toolbar to enable users to perform the functionality that you require. Adding a toolbar to your Web Part provides an intuitive location for controls that your users need to access frequently.

The following code samples show how to create instantiate a ToolBar object in the CreateChildControls method of a Web Part. The samples also show how to invoke the RenderChildren method in the Render method of the Web Part. The RenderChildren method causes the toolbar to be rendered on your Web Part.

C# Code Sample

protected ToolBar webPartToolBar;
protected override void CreateChildControls()
{
webPartToolBar = (ToolBar)Page.LoadControl("/_controltemplates/ToolBar.ascx");
LinkButton saveButton = new LinkButton();
saveButton.Text = "Save Changes";
saveButton.Click += new EventHandler(saveButton_Click);
webPartToolBar.Buttons.Controls.Add(saveButton);
this.Controls.Add(webPartToolBar);
}
  
void saveButton_Click(object sender, EventArgs e)
{
LinkButton saveButton = (LinkButton)sender;
saveButton.Text = "Changes Saved";
}
  
protected override void Render(HtmlTextWriter writer)
{
RenderChildren(writer);
}

Visual Basic .NET Code Sample

Dim webPartToolBar As ToolBar    
  
Protected Overrides Sub CreateChildControls()
webPartToolBar = CType(Me.Page.LoadControl("/_controltemplates/ToolBar.ascx"), ToolBar)
Dim saveButton As LinkButton = New LinkButton()
saveButton.Text = "Save Changes"
AddHandler saveButton.Click, AddressOf saveButton_Click
webPartToolBar.Buttons.Controls.Add(saveButton)
Me.Controls.Add(webPartToolBar)
End Sub
  
Sub saveButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim saveButton As LinkButton = CType(sender, LinkButton)
saveButton.Text = "Changes Saved"
End Sub
  
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
RenderChildren(writer)
End Sub
Tags : sharepoint

Robin Meuré
How to use it in Application Pages (declarative)

To use the ToolBar in your application page and you want to add this declarative do the following.

Add these lines are in the header section of the page:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

The toolbar itself can be placed in a contentplaceholder like so:

<wssuc:ToolBar id="Toolbar" runat="server" CssClass="ms-toolbar">
    <Template_Buttons>
        <wssuc:ToolBarButton runat="server"
            id="ViewSites"
            Text="View Sites"
            ToolTip=""
            OnClick="ViewLink"
            ImageUrl="/_layouts/images/newitem.gif"
            Padding="2px"
            AccessKey="V" />
    </Template_Buttons>              
    <Template_RightButtons>
        <SharePoint:WebApplicationSelector ID="webApplicationSelector" runat="server" Enabled="true"  />
    </Template_RightButtons>
</wssuc:ToolBar>

Which gives you the following result:


http://community.zevenseas.com/Blogs/Robin/Lists/Photos/toolbar.png
Tags :

Page view tracker