Posts Tagged ExtensionMethods

Multiple level navigation in Silverlight

Note: The code for this article can be found at This is actually my first post which concerns Silverlight. I have for the last couple of weeks started to get my hands dirty with some new Silverlight 4 stuff for a new client. I am building the UI (completely in Silverlight) and this article […]

, , ,



Today I made my first codeplex project, SharePointContrib public. The url to it is: I have been working on it for a while now and I have done some testing using Nunit which was quite a challenge but at the same time very interesting. As the documentation says, SharePointContrib is “Contributions, extensions, utilities and […]

, , ,


Using a generic ascx control to display messages to the user

I have many times been involved in projects where the customer wants the application (web/SharePoint) to inform the user when something is successfully completed or for that matter when the app fails. Since I usually implement things using ascx controls (usercontrols) this has in most cases been implemented using a method on the masterpage/page that […]

, , , ,


Nodes with namespace uri:s when modifying web.config file in SharePoint

A while back I wrote a post on how to use a real web.config file when writing modifications to SharePoint. Apparently I had missed that if a node (like the one you see below) has a namespace reference you have to handle that in a special way, thanks to Rikard Uppström for pointing that out. […]

, , , , , , ,


Node demotion does not work with blank (empty) values

While working with node promotion/demotion with xml files I noticed a problem (probably a bug) that occurred when a value was emptied (blanked) in the EditForm. Here´s a rundown of the problem: I start with uploading a new “book” to my newly created Books document library. Filling in all the values. Then I decide I […]

, , , ,


Customize defaultview extension method

This is an extension method that I have used numerous times in feature receivers that creates instances of lists and I needed to customize the default view (AllItems.aspx) on that list. It looks like this: And you can call it like this:    

, ,

1 Comment

DispForm extension method

A while back I write  post about getting the EditForm url of a SPListItem. This is another one of those nice to have extension methods for the SPListItem class. This one gets you the url of the DisplayForm (DispForm.aspx). Here is the code for that extension method: and now you can write code like this: […]

Leave a comment


Sometimes when you run code like this: you will get an exception like so: ”System.Exception: Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.” This can happen especially if you use this kind of code in a loop where you´ll re-use […]

Leave a comment

Making ServerRelativeUrl work on SPListItems

ServerRelativeUrl only work on the SPFile class so you can´t use SPListItem to get access to that property, example: item.File.ServerRelativeUrl But, the SPListItem has a column named FileRef that holds that information so by making an extension method you can get around that: And, now it works!

Leave a comment

Find SPList by using the internal name

SPList instance = web.Lists[“MyCustomList”]; Recognize this little piece of code? I don´t know how many times I have written code like that. What´s the problem with it then? Well, it uses the display name of the list to find it. What if I have a list name like “Custom Lists – Orders that have been […]