• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • All
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • 3D printing
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Chatbots
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DataOps
    • Developers life
    • DevOps
    • Digital Days
    • Digital Twin
    • Docker
    • eHealth
    • Enterprise Architecture
    • Event Sourcing
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • All
    • Bloggers
    • Speakers
Home » How to remove a toolbar header from a SharePoint web part
  • How to remove a toolbar header from a SharePoint web part

    • By Marcel de Vries
    • .NET 14 years ago
    • .NET 0 comments
    • .NET .NET
    How to remove a toolbar header from a SharePoint web part

    *Moved to: http://fluentbytes.com/how-to-remove-a-toolbar-header-from-a-sharepoint-web-part/

    Yes you read it correct, I did some SharePoint development last week. And I must say It was quite a challenge. I was just helping out on a project where we created a feature that combines a custom list deployment with the deployment of a custom page. On this page we place web parts that provide a view to the custom list.

    Now the challenge I faced was to get the deployment working in such a way that we add web parts to the page not showing the toolbar. At first I just laugh and said that I would fix that for them in a few minutes, assuming I could just use the object model, set a toolbar property to false and from that point on have a big hug from my colleague.

    Well I was wrong. Removing a toolbar from a webpart using the object model is something that is just not supported. You can read more about this in e.g. this forum thread.

    After some digging around I finally got the problem solved. I thought I would provide the code snippet here, so you can leverage it.

     

    private static void DisableToolbar(ListViewWebPart lv)

    {

     //  Extract view

     

       System.Reflection.PropertyInfo ViewProp = lv.GetType().GetProperty(“View”,
        System.Reflection.
    BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

     

       SPView spView = ViewProp.GetValue(lv, null) as SPView;

     

       string txt = spView.SchemaXml;

       System.Reflection.PropertyInfo NodeProp = spView.GetType().GetProperty(“Node”,
         System.Reflection.
    BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

     

       XmlNode node = NodeProp.GetValue(spView, null) as XmlNode;

       XmlNode tBarNode = node.SelectSingleNode(“Toolbar”);

     

       if (tBarNode != null)

       {

          XmlAttribute typeNode = tBarNode.Attributes[“Type”];

          // make the contents empty so we realy remove the toolbar …..

          // otherwise you might get a different type of toolbar popup when we have a
          // Migrated site from 2.0

          tBarNode.RemoveAll();

          // re-add the type attribute

          tBarNode.Attributes.Append(typeNode);

          // finally set the toolbar to not show….

           typeNode.Value = “None”;

        }

    //This forces a refresh of the views internal xml or the node’s cild nodes are not populated

     spView.Update();
    }

    Follow my new blog on http://fluentbytes.com

    Share this

Marcel de Vries

View profile

Related IT training

Go to training website

Related Consultancy solutions

Go to infosupport.com

Related blogs

  • Building a custom Kubernetes operator in C#

    Building a custom Kubernetes operator in C# Willem Meints - 2 months ago

  • Transform SpecFlow Table Column

    Transform SpecFlow Table Column Ronald Bosma - 5 months ago

  • Building a passwordless login flow with WebAuthn and th…

    Building a passwordless login flow with WebAuthn and th… Willem Meints - 7 months ago

Data Discovery Channel

  • Explainable AI - Break open the blackbox

  • Toekomstvaste microservice data architecturen

  • Modern Data Platform

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel Always active
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Manage options Manage services Manage vendors Read more about these purposes
Voorkeuren
{title} {title} {title}