Archive for category Code

Simple SharePoint Code Reference

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This is a short example doc I built for a certain vendor that was having issues with some event handler code covering safe calls for doing a lot of basic SharePoint functions. Posted here for reference 🙂 using System; using System.Net; using System.Diagnostics; using System.Collections; using Microsoft.SharePoint; using Microsoft.SharePoint.Navigation; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint.Taxonomy; […]

No Comments

eBay SharePoint 2010 – Coding Practices

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

When we started analysis for upgrading from SharePoint 2007 to 2010 we went through the pre-existing code base of roughly twenty solutions and dozens upon dozens of features and web parts. Much of this existing code base had known issues ranging from security (never use RunAsElevated for user facing components!), to memory leaks, to just […]

1 Comment

Horizontal Full Breadcrumb

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading...

In SharePoint 2010 out of the box you only get the full hierarchy from the ‘Folder Up’ icon in the ribbon. However, if you’ve ever tried to just copy this control and use it in place of the truncated breadcrumb you’ll find it doesn’t quite behave as you want and there is no intuitive way to make […]

5 Comments

Visual Studio Productivity Tools

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

First, if you code, SharePoint or not go download this tool now for Visual Studio 2010. Don’t bother reading the details of why just go do it 🙂 Visual Studio 2010 Productivity Power Tools. Now you’re probably wondering why you just went and installed this extension. In short, it fixes a lot of really simple […]

No Comments

LinkedIn and SharePoint…don’t do it

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So I was asked as part of a proof of concept idea to build an optional system for users to display data from there LinkedIn Profile.

No Comments

Upload Files with Metadata in Client Object Model

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Alright so after my last post you can now bring SharePoint form fields in to a Silverlight form. But now how do you feed that information back to SharePoint? And how do you add metadata to the file at the same time as the upload? This is how! So you can see we first grab […]

2 Comments

Translate SharePoint Fields to SilverLight

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So having the Silverlight Client Object Model in SharePoint 2010 is great. However, some of the most common requests after rich media with Silverlight and SharePoint regard managing data. However, the built in SharePoint 2010 field types can not directly translate to Silverlight controls. This is an example of how I managed to translate most of the common fields to and from SharePoint and Silverlight. Depending on the type of the SPField being passed the correct form field type gets added to the Silverlight form on the fly.

2 Comments

Checking File Status in an EventHandler

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So a common issue people run in to with file driven event handlers in SharePoint is that the event handler triggers on the SPListItem being added not the file write completion. So oftentimes you’ll get odd issues where unpredictably you won’t be able to access the file within your event handler (typically a NullReferenceException). So here’s a simple example for how to see if the file upload has been completed and added successfully to the list item.

No Comments

Programmatically Add a File in SharePoint

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

A simple demonstration function to add a file to an existing SharePoint Library.

10 Comments

Programmatically Set Permissions

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This is some example code I wrote the for the MSDN forums to showcase how you can programmatically set permissions. This code will work for splists or spwebs (in the example it’s SPList permissions, but just changing those calls to go off of Web will switch it). In addition, this shows how to set permissions automatically at feature activation using a SPFeatureReceiver. Double bonus! 😉 Read on for code!

2 Comments