Solved

Moss2007 toolbars in SharePoint 2010 for all sites

Posted on 2013-05-22
1
218 Views
Last Modified: 2013-05-29
I am trying to get the moss 2007 toolbars on document libraries across the whole site but its letting me do it one library/list at a time. I basically go to edit page > edit webpart > show toolbar in the menu.

Is there a way to enable all of them at once in a site?

Thanks!
R
0
Comment
Question by:rsurya23
1 Comment
 
LVL 9

Accepted Solution

by:
kukdai earned 150 total points
ID: 39187705
you can write code for this may be by writing a feature or a utitlity.


here is the code

Open in new window

Addlisttoolbartolist(spweb web,splimitedwebpartmanager wmanager, xmlElement element, string listtitle)
{
system.web.ui.webcontrols.webparts. webpart documentswebpart= (from system.web.ui.webcontrols.webparts.webpart wp in wmanager.webparts where wp.title==listtitle select wp).firstordefault();

if(documentswebpart!=null)
{
changelisttoolwebpart(documentwebpart);
}


}


this is the function where you pass the webpart object.
changelisttoolwebpart(system.web.ui.webcontrols.webparts.webpart wp)
{
if (wp is XsltListViewWebPart)

                     {

                           XsltListViewWebPart lvwp = (XsltListViewWebPart)wp;

 

                           BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;

 

                           MethodInfo ensureViewMethod = lvwp.GetType().GetMethod("EnsureView",  flags);   

        

                           object[] ensureViewParams = { };

                           ensureViewMethod.Invoke(lvwp, ensureViewParams);

                           FieldInfo viewFieldInfo = lvwp.GetType().GetField("view", flags);

                           SPView view = viewFieldInfo.GetValue(lvwp) as SPView;

                           Type[] toolbarMethodParamTypes = { Type.GetType("System.String") };

                           MethodInfo setToolbarTypeMethod = view.GetType().GetMethod("SetToolbarType",

                                                                                                                                  flags, null,

                                                                                                                                  toolbarMethodParamTypes, null);

                           object[] setToolbarParam = { "ShowToolbar" };

                           setToolbarTypeMethod.Invoke(view, setToolbarParam);

                           view.Update();

                     }


}


}

Open in new window


these above two function can be used to solve your problems it is up to you how you want to use them...
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now