maandag 30 november 2009

Wortell Blog

The company I work for Wortell, has a new company blog. This blog will be written by many of my colleagues and can be found at this URL: It will contain blog posts about SharePoint 2010, OCS, Programming, and many more subjects.


donderdag 26 november 2009

Hide the root node of an ASP.NET Treeview control

When using a XmlDataSource object as the datasource of your treeview control, it can be a challenge to hide the root node of the review. (it was for me… )

I found (on this blog)that the XmlDataSource class has a property called Xpath. Assign this property the value of “/*/*” and your root node will be hidden. Pretty easy, isn’t it…

donderdag 12 november 2009

SharePoint – JavaScript OnLoad

Today I needed to fire some JavaScript code when a SharePoint page loaded. There are several ways to do this as far as I can tell, but there is only one way which I liked. After your JavaScript code you should include the following code:

_spBodyOnLoadFunctionNames.push("your method");

My customer needed a (pop-up) page that was printed and closed immediately after it was opened. I did this in the following way:

StringBuilder script = new StringBuilder();
script.Append("function onLoad()");
script.Append("  window.print();");
script.Append("  window.close();");

You should of course not forget to register your JavaScript. :-)

woensdag 21 oktober 2009

SP2010 - Application pages and dynamic masterpages

Remember waaay back when SharePoint 2007 was still used and we could not change the masterpage for application pages. Well, all that has changed. Application pages dynamically adapt to the masterpage of the site they're in.

I can name a bunch of customers who will be very happy with this... :-)

SP2010 - List improvements

Quite some things have improved for lists in SP2010. Some of the improvements are:

transactional cascading deletion (and restriction of deletion)
In the list settings the will be an option to enforce relationship behaviour. This will have 2 options: rerstrict delete and
cascade delete.
1. When an item in the target list is deleted cascade delete will delete ALL related items in this list.
2. Restrict delete will prevent the deletion of an item in the target list if it has one or more related items in this list.

formula based validation
In the list settings you will have the possibilty to select a field and enter a formula for validation. The formula
"=len(Lastname)=30" for instance will limit the name for the Lastname field to 30 characters. Another nice feature
is that you can also fill in the error message that will be displayed to users. Fantastic, isn't it!!

lookups to multiple columns
What else can I say but: sweet!!

SP2010 - Bye bye tables, hello div's

Just a short message: in SP2010 the only table's you will see are the legacy one's for the sake of being compatible with SP2003 and SP2007. All new code will be purely div based!!! I think quite some designers did a happy dance when they heard this. :-)

SP1020 - BCS, theye're awesome

In my opinion of the greatest improvements of SP2010 are the new and improved BDC's. They're so improved that their name has changed to BCS.

The most important feature has to be the fact that they support updating now. This finishes them really off in my opinion.

Another EXCEPTIONAL feature is that you can connect you BCS data to a SharePoint list. Any modifications you make in the list will be applied to your BCS back-end DIRECTLY. You read this right my friend.

As Rolando Jimenez showed in his presentation: you can also show multiple tables from SQL as one record in a SharePoint list. I see this really taking off in SP2010, and becoming one hell of an important feature.

SP2010 - Visually design webparts in VS2010

Okay, so this is not a really big improvement, but still one that makes life easier. From now on, webparts can be designed in VS 2010 by dragging controls onto your webpart. Now I'm to used to inserting controls dynamically in my webparts, but I can imagine having a simple webpart where you have a label, a button and a textbox. These 3 controls can be dragged on to your webparts and presto... you can start coding.

I heard from a lot of beginning developers that they miss this feature. Well guys, you will enjoy SP2010!!

SP2010 - Development on Win7/Vista machines

Right now I'm at the SP2010 conference, and one of the nice things I heard is from now on us dev's have the possibility to develop on our local machines. Yeah, no more VPC's guys!!

It will require a 64-bit OS though. And as Paul Andrew said during his speech it will not be supported for production.

I think this is a great move by the SP team. All of the resources of the PC will be available from now on. (instead of only 70% of the PC's memory for instance) I really look forward to this!

Furthermore, I never could get over the fact that F5 didn't start a debugging session. Wel, in VS2010 (in a web part project) F5 will deploy the wsp for you!!! Yeah, and you can start debugging right from the get-go. Now how awesome is that!!!!

maandag 28 september 2009

OCS Office Communicator Mobile R2 – Automatic sign-in

I recently purchased a Samsung Omnia Pro Mobile phone. This phone runs Windows Mobile 6.1. I like to stay in touch with colleague’s even when I’m not at the office, so I decided to install Office Communicator Mobile on my phone. The install was easy, and communicator works like a charm.

There was just one interesting issue I had: it seemed I could not log out of communicator. According to colleague’s (thanks Paul :-)) I was online all the time. Even when I closed the communicator task in Windows Mobile, I was online. (can you imagine my surprise when no apps were running according to Windows, but I was online) If I logged my self off in Communicator, it would be a couple of minutes before I appeared online again. (even though Communicator was not running!!!)

Looking around in the options of Communicator I found an interesting option with the label: “Automatically sign me in”. This was turned on for me, and I thought that this would log me on every time I turned on Communicator. This (of course) is not the case, because even if Communicator was not running I would be logged in. Since I turned this option off though, I have not had this thing happen to me anymore. So if anyone is experiencing the same thing, just turn this option off, and you will not be online anymore.

maandag 7 september 2009

C# – IRR Function

Today I was working on a financial application for a customer. One of the spec’s was an IRR (internal rate of return) calculation that had to be done. Since C# doesn’t offer any classes that can calculate the IRR, I decided to use the .Net Framework alternative: the IRR method from the Financial Class (in Microsoft.VisualBasic.dll). So one could call this method in the following way:

double IRRValue = Microsoft.VisualBasic.Financial.IRR(ref irrArray, estimate);

Unfortunately this will only work for simple IRR calculations. My customer has an array containing 16 cashflows. I have concluded that the abovementioned IRR method can only calculate arrays that don’t exceed 12 cashflows. If you exceed 12 cashflows the method throws an exception stating “Arguments Are Not Valid". (yes my friend, you are reading this correctly) Furthermore (yes, there is more), if you read the MSDN documentation on this beautiful method you will see that is says: “If IRR cannot find a result after 20 tries, it fails.”. For complex calculations chances are that 20 is to little, and thus you will get the aforementioned exception again.

Now you might be wondering how I solved this horrid issue… I simply used an open-source implementation of the IRR function. It is written in C#, and can be downloaded from this link. More info about this IRR implementation can be found on the official site. For me this worked like a charm.

vrijdag 14 augustus 2009

SharePoint master pages – Style library site relative URL

I am an developer, but sometimes I have to do some styling. On a recent project I added a style sheet to the style library. next thing I wanted was to reference this style sheet in a master page. I wanted to do this in a manner so that the style library would be referenced by a site relative URL. (so http://test/style%20Library and http://test123/style%20library should both work)

The way to do this is by including the following line in your master page:

<link rel="stylesheet" type="text/css" href="../../Style%20Library/YouFolder/YourStyleSheet.css" />

SharePoint FBA – Adding users programmatically

Colleagues of mine have implemented Forms based Authentication (FBA) for a customer site. The customer was so “kind” to supply them with a Excel sheet containing 1200 usernames, email addresses and passwords. Every single user had to be imported into the FBA SQL database and certain SharePoint groups.

I decided to make a friendly web part which allows the user to select a *.csv file on their hard drive, and with a push on the button to import the users from the file.

Adding users to FBA went smooth, but adding those users to SharePoint groups threw Exceptions. Weird thing was, that even though I could not add the users through code, those users could be found in the People picker (and thus could be added through the user interface).

After adding users to FBA, I had to add them to SharePoint explicitly, before I could put them in SharePoint groups through code.

So the code for adding users to FBA, and adding the SharePoint groups should look like this:

MembershipUser existingUser = System.Web.Security.Membership.GetUser(“TheUserName”);
if (existingUser != null)
    Membership.DeleteUser(“TheUserName”, true);

MembershipCreateStatus createStatus;
Membership.CreateUser(“TheUserName”, “ThePassword”, “TheEmailAdress”, "FbaPasswordQuestion", "FbaPasswordAnswer", true, out createStatus);

if (createStatus == MembershipCreateStatus.Success)
    string userName = "aspnetsqlmembershipprovider:" + “TheUserName”;  //Don’t forget to prefix the username with the membership provider you defined

    web.SiteUsers.Add(userName, “EmailAdress”, “Name”, "Batchimport");
    SPUser user = web.SiteUsers[userName];
    if (user != null)

        throw new Exception("The user was added to FBA, but couldn't be added to SharePoint.");
    throw new Exception("The user could not be added to FBA.");

maandag 16 maart 2009

SharePoint Best Practices Seminar

On April 3rd 2009 a SharePoint best practices seminar will be held at Microsoft headquarters in the Netherlands.

Some of the speakers will be: Joel Olesson, Mike Watson, Daniel McPherson and Waldek Mastykarz.

I expect loads of interesting SharePoint subjects, so I will definitely be there! You can register here. (but hurry because there's a limited capacity).

Remove Folder from style library

I recently had to modify a feature which had provisioned some stylesheets and images to the style library. One of the things I had to do was remove all the provisioned files and folders when the feature was deactivated.

Amongst others a folder within IMAGES had to be removed in an feature-receiver during FeatureDeactivating. To do this I followed the next steps:

First I got a reference to the Style Library:
SPWeb rootWeb = ((SPSite)properties.Feature.Parent).RootWeb;
SPList styleLibrary = rootWeb.Lists["Style Library"];

Next I had to get a reference tot the IMAGES folder. There probably are more ways to do this, but what I did was loop through the folders until I found the IMAGES folder:
foreach (SPFolder folder in styleLibrary.RootFolder.SubFolders)

  if (folder.Name.Equals("Images", StringComparison.OrdinalIgnoreCase))

Now, last-but-not-least, in the above if statement you should find the folder you're looking for and delete it:
for(int i = 0; i < folder.SubFolders.Count; i++)
  if(folder.SubFolders[i].Name.Equals("MyFolder", StringComparison.OrdinalIgnoreCase))

woensdag 4 maart 2009

stsadm upgradesolution and new features

I've had a few people come up to me and ask me why they can't find their new features after they did an stsadm -o upgradesolution.

To make things clear, the scenario is as following: example.wsp is deployed and contains two features, feature-A and feature-B.

If, for example, you add a new feature (feature-C) to example.wsp, and deploy it using stsadm -o upgradesolution, then you will not find the new feature in your feature overview. Neither in the site features nor the site collection features will you find feature-C.

It looks like feature-C wasn't deployed. But wait.... the feature can be found in the 12-hyve. See what happened? The feature is deployed but not installed!

So if you do a simple stsadm -o installfeature and presto: the feature will appear in the features overview.