5/20/2010

SharePoint 2010: Part 2: Preparing for 70-573 TS Microsoft SharePoint 2010, Application Development

 

Tonight I get to play with the Dialog Framework and the Ribbon… Both of these are client side and UI features. Check out the links below, and also do a web search on these topics. There’s a lot of good blog articles and good content at MSDN.

 

Skills Being Measured:
Working with the SharePoint User Interface (19%)

Implement a dialog by using the Dialog Framework

  • This objective may include but is not limited to: Create dialogs from JavaScript or from server side, display dialogs

Create a custom ribbon object

  • This objective may include but is not limited to: adding custom actions to the ribbon, customizing groups, customizing tabs, customizing the existing ribbon

 

My Dialog Notes:

A Dialog is basically a page displayed in a DIV. The V4 master page will hide all of the normal navigation parts of the page.

For example:

My Ribbon Notes:

  • Ribbon options can be created starting with the same Feature elements you used for 2007 custom menus (<CustomAction>), plus a new <CommandUIExtension> child element with a lot of new options.
  • There are two Location attributes, on in <CustomAction> and one in <CommandUIExtension>.
  • The <CustomAction> element is basically “which ribbon” while the <CommandUIExtension> element is basically “where in the ribbon”
  • The <CommandUIExtension> element has a very important attribute named Location that indicates which ribbon and the location in the ribbon to modify. VS 2010’s Intellisense do not help with “Location”. Details for out of the box options can be found here:
        C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14
        \TEMPLATE\GLOBAL\XML\CMDUI.xml
    Documention can be found here: http://msdn.microsoft.com/en-us/library/ee537543.aspx
  • Location is in the form of    Ribbon.tab.group.controls
  • Understand “_children” in the Location element
  • Unlike 2007 where you added menu options with <CustomAction> you can now add all kinds of controls: Buttons, Text boxes, Menus…
  • Unlike 2007 the Ribbon options can respond the status of other items on the page, such as if a list item has been selected.
  • Two approaches: Declarative (Features) and Imperative (writing code)
  • Bottom line… the Ribbon, the new feature options, and the context sensitivity features are cool.

 

Links

 

MSDN: Server Ribbon in SharePoint Foundation (drill down to find the walk throughs)
http://msdn.microsoft.com/en-us/library/ee540027.aspx

A very quick demo of a Dialog:
http://www.andrewconnell.com/blog/archive/2009/12/08/sharepoint-2010-dev-tidbit-ndash-want-to-create-your-own.aspx

An tutorial of both a Dialog and a Ribbon update:
HOL10 - Developing SharePoint 2010 User Interface Ribbon and Dialog Customizations
This hands-on lab walks you through adding a custom action to the SharePoint 2010 ribbon, and creating a Web Part that uses the Dialog Framework.
http://www.microsoft.com/downloads/details.aspx?FamilyID=c010fc68-b47f-4db6-b8a8-ad4ba33a35c5&displaylang=en

Another example that shows both a Dialog and a Ribbon update
http://blogs.msdn.com/jfrost/archive/2009/11/08/how-to-display-a-sharepoint-dialog-from-ribbon-button-and-get-selected-item-context.aspx

A 1 hour video demo of the Ribbon and Dialogs:
http://msdn.microsoft.com/en-us/sharepoint/ff462046.aspx

Another MSDN video: Module 10: Creating Dialog Boxes and Ribbon Controls for SharePoint 2010
http://msdn.microsoft.com/en-us/sharepoint/ee513157.aspx

Creating a Custom Ribbon Tab in SharePoint 2010
http://sharepointsolutions.com/sharepoint-help/blog/index.php/2009/10/creating-a-custom-ribbon-tab-in-sharepoint-2010/

5/18/2010

SharePoint 2010: Part 1: Preparing for 70-573 TS Microsoft SharePoint 2010, Application Development

See “Part 0” here.

 

A note (and a guess on my part): This is exam is not an “upgrade from 2007 exam”, so I am assuming when there is a reference to objects such as “SPWeb” that what we will need to primarily know the “core” properties, methods and how to’s, and not just what is new or deprecated. With that in mind, and the fact 2010 is VERY backward compatible, I have a number of references to 2007 resources. (2007 books are now really cheap on Amazon and a used book stores!)

 

Skills Being Measured:
Working with the SharePoint User Interface (19%)

Manage SPSite and SPWeb programmatically by using Visual Studio 2010

  • This objective may include but is not limited to: creating sub webs, referencing SPFiles, manipulating property bag, when to call Update, referencing SPContext, SPSite, SPWeb,  SPSite.OpenWeb, SPWeb.Webs, feature activiation and deactivation
    This objective does not include: trivial cases such as setting title and other loose properties of the objects

This SPSite, SPWeb and related core objects have not changed too much (if at all) from 2007, so a number of the links below are for 2007, but apply to 2010.

 

Here’s a couple of the interesting changes:
      Four interesting changes to the SharePoint Foundation 2010 API

 

As the core has not changed too much, many of the existing book and web resources will still apply:

 

MSDN:  (this is the list of the objects mentioned, but don’t limit yourself to just these!)

Server and Site Architecture: Object Model Overview
http://msdn.microsoft.com/en-us/library/ms473633.aspx

 

SPSite: http://msdn.microsoft.com/library/microsoft.sharepoint.spsite%28office.14%29.aspx

SPWeb: http://msdn.microsoft.com/library/microsoft.sharepoint.spweb%28office.14%29.aspx

SPFile: http://msdn.microsoft.com/library/microsoft.sharepoint.spfile%28office.14%29.aspx

SPContext: http://msdn.microsoft.com/library/microsoft.sharepoint.spcontext%28office.14%29.aspx 

SPSite.OpenWeb: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.openweb.aspx

SPWeb.Webs: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.webs%28office.14%29.aspx

 

Blogs and other:

Activate features through code
http://vspug.com/nicksevens/2007/09/04/activate-features-through-code/

Working With Features Through Code
http://vspug.com/ethan/2007/09/23/working-with-features-through-code/

Programmatically Activate a Feature
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/22/how-to-programmatically-activate-a-feature.aspx

 

Writing to the Property Bag using CAML in SP2010 (or setting Property Bag values using a feature!)
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/writing-to-the-property-bag-using-caml-in-sp2010.aspx

SharePoint Property Bag
http://www.codeproject.com/Articles/43601/SharePoint-Property-Bag.aspx

The SPWeb Property Bag
http://www.iwkid.com/blog/Lists/Posts/Post.aspx?List=a9757dac-2555-45d8-a213-15c89d282620&ID=42

 

What is the difference between SPListItem.SystemUpdate and SPListItem.Update Method
http://www.codegain.com/articles/sharepoint/developmentprogramming/what-is-the-difference-between-splistitem-systemupdate-and-splistitem-update-method.aspx

 

.

SharePoint: Microsoft’s Eval SharePoint 2007 VHD Download is Now for Hyper-V Only!

 

http://www.microsoft.com/downloads/details.aspx?FamilyID=67f93dcb-ada8-4db5-a47b-df17e14b2c74&DisplayLang=en

 

This URL used to point to a 32 bit VHD that would work in Virtual PC on just about any 32 bit Windows from XP on.  According to the link above It now requires:

  • Windows Server 2008 Hyper-V is required to use this virtual machine
  • In addition to the system requirements for Windows Server 2008 as described in the release notes, a 64-bit system with hardware-assisted virtualization enabled and data execution prevention (DEP) is required.
  • It is also recommended to ensure that you have a clean install of x64 edition of Windows Server 2008 to be able to use the Hyper-V technology.

When I try to start this VHD from VPC I see the initial BIOS startup and then a black screen. The base PC’s Task Manager shows a lot of CPU activity, but nothing but a black screen in VPC.

Doing some web searching it appears that it can be made to run on VPC, but you will need to have access to a machine with Hyper-V to “fix” it.

Here is one possible solution: http://codebetter.com/blogs/peter.van.ooijen/archive/2010/01/31/from-hyper-v-back-to-virtual-pc.aspx

 

I have not tried the steps in the above link yet, but if you have gotten this to work in VPC, then please post a comment with instructions or a link.

 

.

5/17/2010

SharePoint: How to Hide a Site Template in Single Site Collection

(this is for SP 2007, not tested with 2010)

 

Here’s a quick little “hack” to hide a template in “Site Actions, Create, Sites and Workspaces” for just a single site. This does require access to the web front end servers.

 

Steps:

  1. In ...\12\TEMPLATE\LAYOUTS find newspweb.aspx and open it in Notepad or your favorite editor.  (you may want to backup this file first!)
     
  2. Just before last line of the file ("</asp:content>") add the following JavaScript
     
  3. In the JavaScript edit the "if (window.location" line for your site collection
     
  4. Also edit the "if (selList.options[i].value==" line for the template IDs(*) you want to hide
     
  5. Copy this page to each of your web front end servers

Notes: This will not survive an upgrade to SharePoint 2010 and would have to be repeated after the upgrade. This should be added to any “rebuild” documentation such as a Disaster Recovery Plan.

(*) for a list of template IDs see here: http://www.devexpertise.com/2009/02/06/sharepoint-list-template-ids-and-site-template-ids/

 

 
<script> 
 
// change this line for your site collection
if (window.location.href.indexOf('/sites/training/')>-1)
{
  // remove items loaded with the page load
  removeitem();  
 
  // remove items loaded with a tab click
  var oldClientCallback = ClientCallback
  ClientCallback = function(result,context)  
  {
    oldClientCallback(result,context)
    removeitem()
  } 
 
  function removeitem()
  {
    var selList = document.getElementById("ctl00_PlaceHolderMain_InputFormTemplatePickerControl_ctl00_ctl00_LbWebTemplate")
    for (var i=0;i<selList.length;i++)
    {
      // update this line with your template IDs
      if (selList.options[i].value=="STS#0" | selList.options[i].value=="MPS#1")
      {
        try
        {
          selList.remove(i) 
        }
        catch (err) {}
        break;
      }
    }
  }
} 
 
</script> 
 

 

 

This follow is the same as the above, but may be easier to copy and paste…

<script>

// change this line for your site collection
if (window.location.href.indexOf('/sites/training/')>-1)
{
  // remove items loaded with the page load
  removeitem(); 

  // remove items loaded with a tab click
  var oldClientCallback = ClientCallback
  ClientCallback = function(result,context) 
  {
    oldClientCallback(result,context)
    removeitem()
  }

  function removeitem()
  {
    var selList = document.getElementById("ctl00_PlaceHolderMain_InputFormTemplatePickerControl_ctl00_ctl00_LbWebTemplate")
    for (var i=0;i<selList.length;i++)
    {
      // update this line with your template IDs
      if (selList.options[i].value=="STS#0" | selList.options[i].value=="MPS#1")
      {
        try
        {
          selList.remove(i)
        }
        catch (err) {}
        break;
      }
    }
  }
}

</script>

5/15/2010

SharePoint 2010: Preparing for 70-573 TS Microsoft SharePoint 2010, Application Development

 

Welcome to my series of cram sessions to prepare for the new SharePoint 2010 exams. I’m going to start with the first development exam, 70-573.  For details on the whole set of 2010 exams see here.

This is kind of “Part 0” of the series and will serve as a backgrounder and a place to post general links for 70-573 prep.  Keep checking back here as I will be updating this page as I work though all of the topics.

 

Part 1, Part 2, Part 3, Part 4, Part 5, (more to come…)

 

Background Skills

SharePoint is a Windows Server based product created using ASP.NET, so you will need developer skills in the following before even starting to work on SharePoint Certification:

  • Solid VB.NET or C# skills  (2.0, 3.0 and 3.5)
  • Solid ASP.NET skills
  • and a host of other related skills:
    • Workflow
    • WCF
    • JavaScript (and JQuery is a good idea)
    • HTML / DHTML
    • CSS
    • Silverlight
    • AJAX
  • and don’t forget:
    • User interface design skills
    • An understanding of user “accessibility” issues (and legal concerns)

Classes

Here’s a few of the classes available at MAX Technical Training that will be of value:

MA-1038 Advanced SharePoint Training for Developers (for 2007 and 2010 development)

MA-1041 Exploring Microsoft Visual Studio 2010 Using Visual Basic

MA-1042 Exploring Microsoft Visual Studio 2010 Using Visual C#

MA-1045 Microsoft LINQ Using Visual C# 2008

MS-6461 Visual Studio 2008: Windows Communication Foundation

MA-1055 Microsoft Silverlight 4 Using Visual C# 2010: Volume 1

 

Useful Links for 70-573

 

SharePoint 2010: I’m Studying for the new Exams! (you can follow along…)

 

Exam time!

I’ve been playing with 2010 for nine months now. Wow, time flies… I’ve decided to start the final “cram” for the exams and thought I would share what I’ve learned along the way. So I’ll blog about how I’m studying for each of the “Skills Measured” in Microsoft’s exam descriptions and the resources I’ve found.

 

 

About the Exams

  • For a list of the 2007 and 2010 exams see here: http://techtrainingnotes.blogspot.com/2010/02/sharepoint-certification.html
     
  • The 2010 exams won’t be available until July 12th 2010 (humm… two months after the “official” announcements on May 12th.)
     
  • There are two “tracks” with two exams each:
     
    •  Development:
      • 70-573 TS: Microsoft SharePoint 2010, Application Development
      • 70-576 PRO: Designing and Developing Microsoft SharePoint 2010 Applications
         
    • Administration (ITPRO)
      • 70-667 TS: Microsoft SharePoint 2010, Configuring
      • 70-668 PRO: Microsoft SharePoint 2010, Administrator
         
    • RUMORS and such…
      • and according to here (and other blog sites) if you pass both 70-573 and 70-576 you will get
      •   SharePoint 2010 MCPD (Microsoft Certified Professional Developer).
        BUT… I can’t find this on any Microsoft site so far…

      • and according to the same sites if you pass both 70-667 and 70-668 you will get
           SharePoint 2010 MCITP (Microsoft Certified IT Professional)
        This may be correct as the Microsoft pages use the term “PRO”, but they do not outright say MCITP.
         
      • Both of those would be fantastic, but I think the TS and PRO are pretty clear as being MSTS and MSITP (if you know otherwise, and have a Microsoft reference, please post a comment)
      • The same sites say that you must pass the first exam to take the second, i.e. you must pass 70-573 to qualify to take 70-576
        BUT… this is not stated on any Microsoft site so far…

 

In the end…

  • I’ll have passed some exams and have some new cool certifications to brag about!
  • I’ll have the content I need for the boot camps I plan to offer though MAX Technical Training
  • I’ve hopefully made the exam prep easier for you
  • and I’ll have lots of new ideas for blog articles!

and…

  • I will not be passing on anything that might be covered under NDA (Non Disclosure Agreement) or any question I might see in the exams when I finally take them.

 

So follow along and you can share what I find and maybe share my pain…

 

My first exam will be 70-573, and the fun starts here: http://techtrainingnotes.blogspot.com/2010/05/sharepoint-2010-preparing-for-70-573-ts.html

 

.

SharePoint: Should you still get certified on 2007?

 

SharePoint 2010 is now here, so should you waste time on the 2007 certs?

 

My opinion? Get the 2007 certs, especially if you are looking at the development certs.

 

Why?

  • The core API for 2010 is largely unchanged from 2007. So what you learn about 2007 is 95-99% reusable with 2010.
  • 2007 uses .NET Framework 2.0 (and 3.0 for workflows) while 2010 uses 3.5  (NOT 4.0), so no major changes in core .NET skills
  • The 2010 exams will not be available until July at the earliest.
  • Having both 2007 and 2010 certs on your resume will look good! 
  • 2007 is not going away soon – you should know how to write code to support both
  • Most of the code you create for 2007 will work unchanged, or maybe with just a recompile, in 2010
  • There are a LOT of good prep tools for 2007: books, blogs, practice tests and lots of knowledgeable people to ask questions of in the MSDN forums.   (and the 2007 books are now CHEAP in the used books stores, Amazon and others)

 

 

Lets take a look at 2007’s 70-541 and 2010’s 70-573

I’m now prep’ing for the new exams and I started by looking at “what’s new” vs. “what I might already know from 2007”. I will share what I discover in the study process in this blog, so stay tuned…

 

So here’s what I have found in the first pass…

 

If you go to 70-573’s page at Microsoft Learning here, either MSL made a big mistake (most likely) or they are giving you a hint…

      image

 

So what would be some of the changes and new topics be?

 

Note: I have not seen the exams yet, so there is some guessing here.

In general:

  • IIS 6 skills for 2007 and IIS 7 skills for 2010 (IIS is listed in 541, but is not listed in 573, but you still need to know about it)
  • Tools!  Visual Studio 2005 vs Visual Studio 2010  (if you know 2005 or 2008, then 2010 itself is not a big surprise) It does sound like Visual Studio 2010 features are a very important part of the exam.
  • STSADM for 2007 and STSADM and PowerShell for 2010
  • Business Connectivity Service (BCS) -- Business Data Catalog in was not available in WSS, so it is not a topic in 70-541, but Business Connectivity Service (BCS) is part of the WSS equivalent in 2010, SharePoint Foundation

 

Section by section review of (and guesses about) the “Skills Measured” tab found here:

  • Working with the SharePoint User Interface (19%)
    • Manage SPSite and SPWeb programmatically – this is the core API and is largely unchanged
    • Implement a dialog by using the Dialog Framework – this is new in 2010
    • Create a custom ribbon object – this is new in 2010 (got to highlight the Ribbon!)
    • Customize navigation programmatically (TopNav, Quick Launch, Custom Actions) – the core is unchanged, but there are a number of new features for Custom Actions and the Ribbon
    • Create and apply branding to a SharePoint site --
      • master pages, content pages, application pages, placeholders, page layouts – the core is the same as 2007, but there are some details to learn
      • programmatically working with themes – this is largely new for 2010
      • deploying CSS, CSSlink, ScriptLink – the CSS files have been updated, and you will need to know about the “old” vs the “V4” files, but not much new here
      • Important note in this section “This objective does not include: graphic design, creating a CSS”, so no “branding”, mostly  a focus on how to interact with the above with code
         
  • Developing Web Parts and Controls (21%)
    • Create Web Parts – largely unchanged from 2007, except for “Visual Web Parts”
    • Create connectable Web Parts – I don’t think there are any changes here
    • Debug Web Parts – core debugging is unchanged, but you have new tools in 2010: the new log tools, correlation IDs, developer dashboard
    • Create and implement delegate controls – while this is not new, it was not listed in the 2007 70-541 “Skills Measured”
       
  • Developing Business Logic (19%)
    • Workflows! In 2010 we now have a lot of new tools, SPD reusable workflows, the ability to import SPD workflows into VS 2010
    • Note: Interesting that the “Skills Measured” says “This objective does not include: trivial cases such as workflows with no custom actions, initiation data, association data.” Read that one carefully – I think it says that custom actions, initiation data, association data are important topics, so make sure you know how to create these.
    • Create a custom workflow action – Similar to SPD 2007 custom actions
    • Customize Enterprise Content Management (ECM) – The topics here sound much like 2007 (but I need to look up “token usage”)
    • Create, implement and debug a Timer Job – much of what you know from 2007 still applies, but there new features and things you need to know about Central Admin and PowerShell…
    • Create and modify Business Connectivity Service model in Visual Studio 2010 – New for 2010!
    • Manage Users, Groups, Permissions (SPGroups, SPUser, permission inheritance, all securable objects, SPRoleDefinition, SPRole, SPRoleAssignment) – largely unchanged from 2007
       
  • Working With SharePoint Data (22%)
    • The core API topics should be the same as 2007, but there are a number of additional Framework 3.5 and SharePoint 2010 things to know…
    • Access list data by using the Server object model – New things here: LINQ (3.5 and the SharePoint 2010 API), Query Governor
    • Access (CRUD) data by using the Client Object Model – Interesting wording on this one – Note the references to how the Client Object Model can be accessed: .Net, Silverlight, JavaScript, CAML, etc.  I would also add JQuery to that list…
    • Work with documents programmatically – the core of this section is unchanged from 2007
    • Work with the meta data – lots of new stuff here
    • Extending SharePoint Search – should be very similar to 2007
    • Implement and debug code that executes in an alternative security context – sounds the same as 2007
    • Create and modify a custom content type – very similar to 2007, but you now have new tools in Visual Studio 2010 to help
       
  • Stabilizing and Deploying SharePoint Components (19%)
    • Manage a solution in Visual Studio 2010 – the core topics for Solution Packages has not changed, but the tools have!  Think Visual Studio 2010 here, not just SharePoint solutions. New topics include Sandbox solutions
    • Manage a feature by using Visual Studio 2010 – again think “Visual Studio 2010” for this topic. The feature/element XML has been expanded, but your core 2007 knowledge still applies (and knowing how to manually create and deploy these is important.  But… know the VS 2010 wizards and options.
    • Store and retrieve configuration data – this all sounds like core 2007 topics
    • Create a site definition by using Visual Studio 2010 – there’s that “Visual Studio 2010” thing again!
    • Manage SharePoint object life cycle by using the Dispose API – critical top regardless of the version – should be largely the same as 2007 and in general a “.NET best practices” topic.
    • Develop, debug, and deploy sandboxed solutions – all new!

 

What else do you need?

Although not listed in the “Skill Measured”, to be successful in SharePoint development you also need:

  • Solid VB.NET or C# skills
  • Solid ASP.NET skills
  • Good SQL skills
  • and a host of other related skills:
    • Workflow
    • WCF
    • JavaScript (and JQuery is a good idea)
    • HTML / DHTML
    • CSS
    • Silverlight
    • AJAX
  • and don’t forget:
    • User interface design skills
    • An understanding of user “accessibility” issues (and legal concerns)

 

How would I do if I took this exam with my 2007 skills?

I think would get at least a 50% (I’m good at multi-guess exams!), and with the “playing around” I’ve done so far, maybe 60-69%.  But I doubt I would pass it without a lot of study.

 

I will revise this as do further study for the exam. There’s still a lot of “I don’t know what I don’t know”!

 

Please post comments with anything you think I missed or misstated.

I will not allow any comments that might violate NDA or might be about actual questions in the exam.

.

SharePoint: Change or Hide the Bullet Image in Quick Launch

(Only for SharePoint 2007 as SharePoint 2010 does not have bullets in Quick Launch!)

 

Sometimes it’s the little things…

I had a request where a site owner wanted to change just the bullet used in Quick Launch. They did not want to create a custom theme or do a complete rebranding of the entire site, just change the bullet.

 

So…

Create your new bullet image in your favorite paint program (JPG or GIF format) and upload it to a library in your site, or if you have server access to the Images folder in Layouts. 

Use SharePoint Designer to edit the master page and add the CSS below just after these two lines:
   <SharePoint:CssLink runat="server"/>
   <SharePoint:Theme runat="server"/>

Or, if you want to do a quick test, instead of editing the master page add a Content Editor Web Part (CEWP), edit the CEWP, click the Source Editor button and paste the following.

 

<style>
table.ms-navitem td,span.ms-navitem {
background-image:url("/sites/training/Shared%20Documents/myBullet.gif");
}
</style>

 

The result (with a horrible bullet image!)

       image

Hopefully you are a better artist than I am!

 

 

If you just want to hide the bullet then set background-image to none:

     background-image:none;

       image

 

.

SharePoint 2010: Evaluation VHD download available

 

The 2010 VHD is no longer available from Microsoft…

 

Microsoft has released a new pair of VHD images for SharePoint 2010 evaluation. This is the final release (RTM) version.

To run these you will need Windows Server 2008 R2 with the Hyper-V role enabled. At least 8 GB of RAM is recommended.

 

2010 Information Worker Demonstration and Evaluation Virtual Machine (RTM)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=751fa0d1-356c-4002-9c60-d539896c66ce

 

Virtual machine “a” contains the following pre-configured software:

  1. Windows Server 2008 R2 Standard Evaluation Edition x64, running as an Active Directory Domain Controller for the “CONTOSO.COM” domain with DNS and WINS
  2. Microsoft SQL Server 2008 R2 Enterprise Edition with Analysis, Notification, and Reporting Services
  3. Microsoft Office Communication Server 2007 R2
  4. Microsoft Visual Studio 2010
  5. Microsoft SharePoint Server 2010 Enterprise Edition
  6. Microsoft Office Web Applications
  7. Microsoft FAST Search for SharePoint 2010
  8. Microsoft Project Server 2010
  9. Microsoft Office Professional Plus 2010
  10. Microsoft Visio 2010
  11. Microsoft Project 2010
  12. Microsoft Office Communicator 2007 R2

Virtual machine “b” contains the following pre-configured software:
  1. Windows Server 2008 R2 Standard Evaluation Edition x64, joined to the “CONTOSO.COM” domain
  2. Microsoft Exchange Server 2010

5/07/2010

SharePoint: Hide the TreeView Icons

 

The following works for both SharePoint 2007 and SharePoint 2010.

 

How can I get rid of the icons in the Tree View?

A while back I got an interesting request… how can I get rid of the icons in the Tree View?  That’s a question I would have never thought to ask!  My quick (and wrong) answer was you could probably do this by changing the attributes of the TreeView control in the master page using SharePoint Designer.  After a bit of trial and error I did come up with a JavaScript solution.  (and I’m sure someone will post a two line jQuery version!)

The end result is much cleaner!

 

The before:                                      and the after:                                  and with lines:

    image      image     image

 

How to do it…

Hiding the icons takes two JavaScript tricks. The first one removes the images on the initial page load. The second intercepts the web service calls to retrieve further expansions of the tree. I may have missed one or more icon types, but that is easy to fix.

 

To use this code:

  • For testing: Add Content Editor Web Part for testing. In 2007 click the Source Editor button and paste the code below. For 2010 save the code below to a text file, upload the file to a library and in the CEWP add a link to the uploaded text file.
  • For actual use: Add this code to the master page anywhere after where the tree is loaded

You will need to use SharePoint Designer to add the tree viewlines.

  • Open the site in SharePoint Designer
  • Open the master page and search for “ShowLines”
  • Change ShowLines = “false” to ShowLines = “true”

            image

 

 

The Code…

The following is offered with no warranties!    :-)

 

Note: Do a search of the HTML of a page where you have the tree view enabled.

   For SharePoint 2010 replace:
      "ctl00_PlaceHolderLeftNavBar_WebTreeView"
   with:
      “ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewV4”

   or maybe:

      “ctl00_PlaceHolderLeftNavBar_ctl01_ctl01_WebTreeView”

  1. Display the page
  2. Use the browser’s View Source option to display the HTML
  3. Search for “WebTreeView” and find the ID

 

 

There are two copies of the code below, one is “pretty formatted” and one is plain text that may be easier to copy and paste.

 

 
<script>
 
// Step 1: hide icons on the initial page load...
 
//get the tree DIV
var tree = document.getElementById("ctl00_PlaceHolderLeftNavBar_WebTreeView");
 
//get the treeview rows
var trs = tree.getElementsByTagName("TR");
 
//loop through the rows and hide the images
for (i=0;i<trs.length;i++)
{
  var tds = trs[i].getElementsByTagName("TD");
  if (tds.length>0)
  {
    tds[1].style.display="none"
  }
} 
 
 
// Step 2: intercept the web service call and fix up the returned data
 
// make a copy of the SharePoint return handler
var backup=TreeView_ProcessNodeData
 
// create our replacement function
TreeView_ProcessNodeData = function(result, context)
{
  //replace the images with blank.gif  (it*.gif, stsicon.gif and folder.gif)
  result = result.replace(/\/_layouts\/images\/it/g,'/_layouts/images/blank.gif" x="')
  result = result.replace(/\/_layouts\/images\/stsicon/g,'/_layouts/images/blank.gif" x="')
  result = result.replace(/\/_layouts\/images\/folder/g,'/_layouts/images/blank.gif" x="')
 
  //call the SharePoint return handler
  backup(result, context);
}
 
</script>

 

 

The following may be easier to copy and paste:

 

<script>

// Step 1: hide icons on the initial page load...

//get the tree DIV
var tree = document.getElementById("ctl00_PlaceHolderLeftNavBar_WebTreeView");

//get the treeview rows
var trs = tree.getElementsByTagName("TR");

//loop through the rows and hide the images
for (i=0;i<trs.length;i++)
{
  var tds = trs[i].getElementsByTagName("TD");
  if (tds.length>0)
  {
    tds[1].style.display="none"
  }
}

// Step 2: intercept the web service call and fix up the returned data

// make a copy of the SharePoint return handler
var backup=TreeView_ProcessNodeData

// create our replacement function
TreeView_ProcessNodeData = function(result, context)
{
  //replace the images with blank.gif  (it*.gif, stsicon.gif and folder.gif)
  result = result.replace(/\/_layouts\/images\/it/g,'/_layouts/images/blank.gif" x="')
  result = result.replace(/\/_layouts\/images\/stsicon/g,'/_layouts/images/blank.gif" x="')
  result = result.replace(/\/_layouts\/images\/folder/g,'/_layouts/images/blank.gif" x="')

  //call the SharePoint return handler
  backup(result, context);
}

</script>

 

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.