Solved

Moss2007 toolbars in SharePoint 2010 for all sites

Posted on 2013-05-22
1
226 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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