Jun 30, 2008

i Love SharePoint

Because it's pain in the ass to publish Source Code on a Blog, I've just launched the i Love SharePoint Project on Codeplex. That's my playground for anything regards SharePoint, .NET and PowerShell. I'm going to publish all my code there. Related postings will be taged with i Love SharePoint.



Enable inline Code for SharePoint Document Libraries

By default inline Code isn't allowed for ASPX Pages they are not in the 12 Hive's Layout Folder. To enable inline Code for ASPX Pages in a Document Library add the following snippet to the SharePoint's web.config. Place it in the <SharePoint> section between the <SafeMode> {here} <SafeMode> tags.


IncludeSubFolders="true" />


Now inline Code is enabled for the Document Library specified in the VirtualPath attribute.

Be careful with Write-Permissions on that Document Library, could be a security impact!

Jun 29, 2008

Get the Id of a SharePoint List or View

In many cases you need to get the Id of a SharePoint List or a View. Typically you browse to the settings page of the List or View and make it out of the encoded URL - cumbersome. Or you can use my PowerShell Scripts as follows:

At this point you've got the Id of the List. Now get the Ids of the Views:

  • $list.Views format-table -property title, id

Thanks for your attention and bye,


The SharePoint RPC Protocol and .NET

Instead of using the SharePoint built-in Web Service (Lists.asmx) to get List Items, you can use the SharePoint's RPC Protocol - it's quite simple:

System.Net.WebClient client = new System.Net.WebClient();
client.UseDefaultCredentials = true;
string xml = client.DownloadString(http://[server]/[site]/_vti_bin/owssvr.dll?Cmd=Display&List=[Guid]&View=[Guid]&XMLDATA=1);

Now you've got the data as an XML-String and you can use .NET XML processing.

Beside, the resulting XML is not a serialized ADO.NET DataSet! It's an serialized ActiveX Recordset! In other Blogs they typically treat the XML as an ADO.NET DataSet and use the DataSet's LoadXml method. Although you can do that, it can raise trouble, especially with dates.
The correct way to fill a DataSet with the resulting XML is to use a ADO RecordSet. Add a COM reference to "Microsoft ActiveX Data Objects 2.8 Library" and use the following code:

ADODB.Stream xStream = new Stream();

xStream.WriteText(xml, StreamWriteEnum.adWriteLine);

xStream.Position = 0;

ADODB.Recordset rs = new ADODB.Recordset();


OleDbDataAdapter adapter = new OleDbDataAdapter();

DataSet ds = new DataSet();



That's it - the DataTable is now filled and typed absolute correctly!

This approach could also being interesting for integrating SharePoint in VB or VBA Applications.

The SharePoint RPC Protocol and Infopath 2007

Infopath's SharePoint list integration is not that good. Although you're able to define a SharePoint List as a Data Source, you can't filter the List Items on the server side. This means make-or-break, unacceptable for large lists! Furthermore, in browser enabled Infopath Forms you are not able to define filter criterias for Dopdowns and Repeated lists.

Fortunately there's another way to get List Items in your form and to filter them on the server side - The SharePoint RPC Protocol.

Proceed as follows:

Now use the Data Source as usual. That's all.

Jun 27, 2008

Firmenlauf 2008

Gestern bin ich mit meinem Team auf dem Firmenlauf mitgelaufen - Alle haben überlebt!


(Dominik, Martin, Michael, Ich, Dennis und Steven)

@Martin: Gott sei Dank programmierst du besser als du läufst ;-)

Jun 25, 2008

PowerShell & SharePoint - Quick Start

SharePoint and PowerShell are a perfect match. Here's the PowerShell profile I'm using on my Sharepoint Dev. Boxes.

If you haven't a PowerShell profile yet, create it:

  • >new-item -type file $profile -force
  • >notepad $profile
  • Paste in the following snippet or download:
$12HivesDir = "${env:CommonProgramFiles}\Microsoft Shared\web server extensions\12\"
#load Microsoft.SharePoint.dll
#returns the SPSite at the specified URL
function get-spsite ([String]$webUrl=$(throw 'Parameter -webUrl is missing!'))
   return New-Object -TypeName "Microsoft.SharePoint.SPSite" -ArgumentList "$webUrl";
#returns the SPSite object from the specified URL
function get-spweb ([String]$webUrl=$(throw 'Parameter -webUrl is missing!'))
   $site =  New-Object -TypeName "Microsoft.SharePoint.SPSite" -ArgumentList "$webUrl";
   return $site.OpenWeb();
#returns the SPList object from the specified URL and List name
function get-splist ([String]$webUrl=$(throw 'Parameter -webUrl is missing!'),
[String]$listName=$(throw 'Parameter -listName is missing!'))
   $site =  New-Object -TypeName "Microsoft.SharePoint.SPSite" -ArgumentList "$webUrl";
   $web = $site.OpenWeb();
   return $web.Lists[$listName]
  • Save
  • >set-executionpolicy -executionPolicy remoteSigned
  • Reopen the PowerShell 

Now you have. Use it:

  • >$web = get-spweb http://localhost
  • >$web.Title = "Greetings from the Powershell"
  • >$web.Update()
  • Browse to http://localhost and see what's happen.

I've teamed up with Eric Kraus from Microsoft. You can find our joint project for PowerShell 2.0 called SPoshMod on CodePlex. Hope the first release will be availiable soon...

Jun 24, 2008

CRN Solution Award Mobility

Markus und meine abgefahrene Präsentation bei der Verleihung des "CRN Solution Award Mobility".

Schon die Agenda war ein Hammer:

  • Die Band
  • Kurze Werbeunterbrechung
  • Das Opfer
  • Backe backe Kuchen
  • Der grüne Daumen
  • Ursache und Wirkung
  • Vorhang auf
  • Outro

mehr Bilder

In der Präsentation haben wir einen "Software Cake" gebacken um mein Vorgehensmodell "Genesis" vorzustellen.

Link zum Artikel der CRN:

Mehr Durchblick im Ersatzteillager dank RFID

Jun 23, 2008

Hello World!

public static void main(string[] args)
Console.WriteLine("Hello World!");