Development

Do long running operations on SPListItem creation

Events on SPListItems like ItemAdding or ItemAdded are nothing new. Many of you have already used them. Recently I had a requirement to create a new SPSite, when an item in a list has been created. So an ItemReceiver was my choice. But the customer wants something special 🙂 During the creation process, which takes some seconds, the user should see a loading animation. Here comes the problem. The ItemEventReceiver is running in the background, and has no knowledge about the GUI process.

Now Available: Office Developer Tools for Visual Studio 2012

Finally! Now Available: Office Developer Tools for Visual Studio 2012 There are some points to mention, where the final release of the tools differ from previous preview releases: validation experience that helps you to find and fix common errors prior to submitting your apps to the Office Store A continuous integration workflow Windows Azure cloud service projects for creating provider-hosted Apps A dramatically improved Workflow designer The download link: http://aka.

Using .NET 4 with SharePoint 2013

A while ago, I wrote an article about performing operations parallel with SharePoint 2010 (.NET 3.5). –> Execute code in multiple threads (even with SharePoint) Since I am not the only guy with this kind of “problems”, others are writing about SharePoint and .NET. Especially .NET 4.5 and SharePoint 2013. Stephane Eyskens hat posted a nice 6-post series about .NET within SharePoint 2013. Tuples Lazy Loading Sorted Sets Parallel.ForEach .

Caching objects with HttpRuntime

I won’t go into the arguments for using a caching mechanism or not. This post is simply an example for an easy way to cache data. So if you want to store some object in the cache, you can do so very easy. var localizedString = Caching.EnsureObject(resourceName, () => GetOperation(parameter)); As you can see, it really doesn’t matter what type of object the cache will store. class Caching { private static readonly TimeSpan Duration = new TimeSpan(1, , ); /// <summary> /// return cached value, or add and return from cache /// </summary> /// <typeparam name="

Execute code in multiple threads (even with SharePoint)

Since SharePoint 2010 uses .NET 3.5, you can not use the fancy new functions from .NET 4 🙂 So if we need e.g. multi-threaded execution of code, we’ll need to write the code ourselves. But, as you can see, this really isn’t so hard. The basic idea behind this solution of executing code parallel in threads, is that you have an IEnumerable of some kind. This can be a List, or any other IEnumerable.

Major Update to the Fileserveraccess Web Part

In 2008 I’ve released a Web Part, which enables your users to access files on your fileservers through SharePoint. Original post. This Web Part has been downloaded many times. With this new version, I’ve tried to deal with the most asked questions (like Kerberos), which will make the Web Part easier to use. Naturally new features have been implemented, to get you to upgrade to the new version. With this release, the Web Part requires SharePoint Foundation / Server 2010.

Update: WarmupScript

A long time ago, I posted a program which will hit all your sites. With parameters you can specify to hit all sites within a sitecollection. This program has been updated. You can not omit a start Url, and specify “Farm” as parameter. This way, all sites in all sitecollections in all webapplications in all… 🙂 will be warmed up. The warmup will use a HttpRequest to query all homepages.

What to know about the feature folder

One of the first things I used to tell guys new to SharePoint development is: Never ever name the folder of your feature “Feature1”. If you create a solution with WSPBuilder, or did some time ago with VS 2008, you have to rename the folders immediately! This is how a typical SharePoint project looks like, if you create features. I guess most of us have used the mighty WSPBuilder ( http://wspbuilder.

SPUrlUtility.CombinePath

Here is another “watch out” for using the SharePoint object model. SPUrlUtility.CombineUrl(web.Url, string.Empty) The line above will throw an exception, as CombinUrl doesn’t like empty strings. 🙂

StaticName != InternalName

Recently I was trying to fetch a SPField from a SPWeb object. I had SharePoint 2010, so I decided to use the new SPFieldCollection.TryGetFieldByStaticName() Method. You can imagine how surprised I was, that I couldn’t get the field I was looking for. What do we learn? Well, the StaticName of an SPField is not necessarily the InternalName! Here is a link to the MSDN about SPField.StaticName: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.staticname.aspx

Watch out for ContentTypeBindings

If you don’t know ContentTypeBindings, take a short look at: http://msdn.microsoft.com/en-us/library/aa543598.aspx “Content type binding enables you to provision a content type on a list defined in the onet.xml schema.” So we can assign content types to newly created lists. That’s cool 🙂 The ContentTypeBinding feature can, of coarse, contain multiple content types which are bound to multiple lists. Like this: <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ContentTypeBinding ContentTypeId="0x0100yourGuid" ListUrl="Pages" /> <ContentTypeBinding ContentTypeId="0x0100anotherGuid" ListUrl="Pages" /> <ContentTypeBinding ContentTypeId="

Check, if you are within a modal dialog

By now, you probably know that the modal framework from SharePoint 2010 is a great thing 🙂 In case you need to find out if the context is within a modal dialog, you can query for the URL parameter “IsDlg”. if (Page.Request["IsDlg"] != null) { // within a modal dialog } else { // not within a modal dialog }

Empty Admin Recycle Bin items

What is it? Usually the size of the recycle bin is not relevant. But on development machines, you don’t want lots of files in there, which make your databases grow without actually used data. What do you do? Go to the recycle bin, click on “Site Collection Recycle Bin”. The two stages of the recycle bin can be managed independently. The two views on the left let you switch between the first- and second stage.