Solved

Moss2007 toolbars in SharePoint 2010 for all sites

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

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

808 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