?
Solved

Moss2007 toolbars in SharePoint 2010 for all sites

Posted on 2013-05-22
1
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
kukdai earned 600 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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