SharePoint ToolbarButtons in lists

It has been a while since my last post. My new assignment and a new "spare-time project" have been consuming a lot of time.
Recently I am working on a new assignment, developing all kinds of Web Parts and Features and since I'm fairly new to SharePoint I ran into some nice problems.
One of those issues really had me going bananas and although there is a wide SharePoint community out there, I had difficulties finding the solution. So I figured I'd share my findings with you guys.

The problem

Ok, say we have a document library and I want to put an icon in the toolbar of the document library, so I tried to do this with the default custom action locations; but that only allows me to put it inside a menu. Finally I found the solution to this (thanks to Paul Robinson) by adding a ToolBarButton to the ToolBar of the list. Now as you'll notice there's no constructor for these two classes in the Microsoft.SharePoint.WebControls namespace. To get toolbars in your web part, you need to create a control using the Page.LoadControl method, pointing to the relevant user control and casting the results. If you know which controls to use it's simple:First let's have a look at the elements.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
  <CustomAction Id="TestFeature.AddToolBarButtonToList"
    ControlAssembly="TestFeature, Version=, Culture=neutral, PublicKeyToken=9fdd626cc17fc71e"
    Title="New ToolBarButton"
    Description="Use this feature to add a new ToolBarButton to your list menu"

So we register the feature in the list's standardmenu, i used the group newMenu, but it doesn't matter because we need the toolbar. Notice the ControlClass, this is where we define our class which is going to create the ToolBarButton.
In the ControlClass, the CreatChildControls method will be called when the document library is loading:

protected override void CreateChildControls()
 ToolBar listviewToolBar = GetParentToolBar();
 if (listviewToolBar != null)
   // Ok, we have the ToolBar of the listview. Now we can add an extra menu...
   _statusButton = (ToolBarButton)Page.LoadControl("~/_controltemplates/ToolBarButton.ascx");
   _statusButton.Text = "";// Only need the icon, so this left blank intentionally
   _statusButton.ImageUrl = "/_layouts/images/PermissionStatus/authenticated.png";
   _statusButton.Click += new EventHandler(_statusButton_Click);

I have used the .RightButtons to add the icon I need to the most right.

Here's the helper method to get the ToolBar:

private ToolBar GetParentToolBar()
            Control parent = Parent;
            while (parent != null)
                if (parent is ToolBar)
                    return (ToolBar)parent;
                parent = parent.Parent;
            return null;

And finally, handling the click, (which is not yet implemented)

void _statusButton_Click(object sender, EventArgs e)
            throw new NotImplementedException();

And here's the result :

Historical Debugging in VS 2010

Ever had the fun of debugging an application, stepping through the source trying to find the piece of code thats causes an exception? Ever wondered why you couldn't step back from within a catch? Well, with the historical debugging feature of visual studio 2010 you can.

According to Microsoft, the historical debugger supports six mainline scenario's:
  • Application Event Recording
  • Playback Debugging (a.k.a Time Travel Debugging)
  • Record and Playback of Manual Test Failures
  • Debugging Build Acceptance Tests
  • Diagnosing Unit Test Defects
  • Debugging Load Test Failures
The historical debugger can be compared with a black-box in a plane, it logs important events in program execution which allows you to playback these events later.

So how does this historical debugging work?

The data that is being collected is pretty much the same as the information that is normally available when doing standard debugging. The first thing that crossed my mind was "how does this affect the performance?". But when you look at the default configuration, the data being collected and the frequency of when this data is being collected is not that much of a performance issue.

This behaviour can be tweaked by selecting several so called diagnostic events .When these diagnostic events aren't providing enough information, one can choose to collect debugging data at all method entry points, this ofcourse has a downside to the perfomance as all parameters etc. will be collected too.

Historical debugging in action

The historical debugger information will be shown in the normal debugger windows, for most of the information. You can step back, step forward etc. seeing the recorded execution. An example is shown in the screenshot below.

First impression

Unfortunately you cannot change the values of variables / parameters in historical debugging session, this would be a welcome addition. Further more, there is an option to save the sessions to a .tdlog file, but there is no tool to start a log in an enviroment where there is no visual studio etc. This tool will be available in the future though. When it's ready it will be a great tool to troubleshoot "not reproducable" bugs etc. At this moment I think it is just a nice idea which is nowhere near ready, especially compared to tools like AppSight. Another thing I miss is the possibility to change the historical debugging settings per project / application.

Beta SP for BizTalk Server 2006 R2

After focussing on SharePoint the last few weeks, I was checking out some updates on BizTalk and I was surprised to see an announcement about service pack 1 for BizTalk Server 2006 R2 coming soon. Seems they have time to do a servicepack for the old 2006 while 2009 is out there.

The Beta release SP1 for BizTalk Server 2006 R2 has been released today. This service pack is an update for BizTalk Server 2006 R2.  It includes new features , hotfixes of issues that have been discovered internally as well as issues reported by customers. You can download the beta release here.

WebsiteSpark is here

this morning Scott Guthrie announced the new websiteSpark program.
It's a program designed for independent web developers and web development companies that build web applications and web sites on behalf of others.  It enables you to get software, support and business resources from Microsoft at no cost for three years, and enables you to expand your business and build great web solutions using ASP.NET, Silverlight, SharePoint and PHP, and the open source applications built on top of them.

So what's the catch?

surely MS isn't giving you this for free??? Well, that was my first thought anyway... turns out that they actually give you this for almost zero...  There is no obligation to continue to use any of the software after the three years is over, and there are no costs for the three years other than a $100 program fee at the end of the three years. If you want to continue using all the great stuff, you can do that at a charge of $999/year package, or you can only buy the productions server licenses for $199/year (web and database server).

The other good news is that you can upgrade the tooling, for example VS2008 to VS2010. And not to mention the free publicity you get!


I have to admit I was a bit sceptical in the beginning, but if you are a starting web development company or an individual developer (ie Freelance) this is a great cost inexpensive way to have a jump start

A must read if you wanna do unit testing

I met Roy at the European TechEd 2007, great speaker, great writer too! After a tweet about stealing, I thought I'd post something about his book. This book is all you need to quickly get up and running with unit testing, I really like the chapter on making your team/company embrace unit testing.

Scott Gu's coming to the Netherlands

Scott Guthrie is coming to the Netherlands to talk about ASP.Net 4.0, MVC, Visual Studio 2010 and more new stuff coming from Redmond. I just heard that I will be representing Fujitsu Services

TFS 2008 and linked classes

At the company were I used to work we had a lot of shared classes (check this article for more info on shared classes) for all the apps we develop. When I started there in january I asked why they did not have any form of version control. They told me that this was because both vss and tfs could not handle the shared classes. At the time I did not have time to research this, but today I found a few extra minutes.
I made three projects, of which two in the same workspace, created a class in the first project and added the same class as link to the second project. When I added the class as link I got the following warning
.. Ok, now this seems to make sense.. I have both projects in the same workspace so it should not be neccesary to change the bindings..
So far so good... Let's try and change the class in the second project and check in the change from within the second project:
As you can see in the picture above, the path is to the first project...
Change is checked without any problem, let's see if it is really changed in project 1:
It is changed. Ok, so the argument of not having tfs because it cannot manage shared classes is not entirely valid. Let's see what happens when I try to add the class of project one to the third project:


So the shared classes should be preferably in the same solution. If this is not the case, you can still add the class as link to a different solution as long as it is in the same workspace!


Welcome to my blog, you've found it. Now I guess you wonder why you are here, well... check back later and you will find wonderfull posts about Silverlight, Biztalk, SOA, Saas, Sharepoint and so on... stay tuned for more....