The best way to learn to customizing Sharepoint for an ASP.NET guy - use Reflector

This is probably the best best tip I'm going to share so far with regards to Sharepoint.

Think of Sharepoint as a pre-built framework on top of ASP.NET, if you are working within the confines of the multitude of options Sharepoint gives you, then you need a big thick book on Sharepoint.

If you are thinking about customizing Sharepoint, then you're beginning to face a problem I had.

How does it all work, and perhaps more importantly, why does it just not work?

You can resort to Google.  In which case, I hope you find this blog.

Or you can grab Reflector and peek inside the secrets of Microsoft.Sharepoint (WSS) and Microsoft.Sharepoint.Publishing (MOSS) assemblies.

I'll share with some findings real soon.

Tough to love Sharepoint

Recently started doing some work on Sharepoint, it's really tough to love Sharepoint.

At a glance, it seems that this is just a technology that's build on top of ASP.NET, so surely it's got all the goodness of ASP.NET + more build-in goodness.

Actually, I'd almost say it's the opposite.

It's got all the goodness of ASP.NET locked away where you can't easily use to customize your solution.

So if you are after something out of the box with light modifications, Sharepoint is really your friend.

As soon as you want heavy modifications, it feels like a complete road block.

Still, it has some really great publishing features, which distinctively makes it very compelling for an enterprise to use and set up.

I'll have more to say very soon.

Where is the DataRepeater for Silverlight?

I came across a really puzzling thing while playing with Silverlight tonight, try as I might, I couldn't find a DataRepeater style of control.

Basically, this is what I wanted to do:

<StackPanel x:Name="actions" Margin="10,0,10,5" Orientation="Horizontal" >
<HyperLinkButton Content="{Binding ActionName}" Click="Action_Click" />
</StackPanel>

And then bind these to an array of actions in the datacontext.


Sadly, StackPanel doesn't support ItemTemplates, and looking around, it seems that the only controls that supports binding collections properly are ListBox and TabControl.


The Grid control is purely for positioning.


The ItemsControl (and the child class ListBox) supports ItemTemplate, but refuses to tile my hyperlinks one after another horizontally, until the width is full and it wraps around.


Bummer.


I've settled temporarily with adding the HyperLinkButtons in the codebehind inside a foreach loop.  But not using databinding for this task makes me sad.


I will get to the bottom of this.



 


Your windows service started and stopped

The name-of-your services on Local Computer started and stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.

I had fun with this one for a bit.  Developing Windows Service is one of those "I rarely do this" activities.  So when I got one of these errors when I start my service, immediately I switch into "Ah I must have forgotten something" mode.

  • May be the process started and didn't do anything and finished
  • May be the timer didn't go off
  • Perhaps I need to spawn a thread to listen / sleep

I couldn't attach a debugger to the service given that it doesn't stay running.  So that limited my options a bit.

Turns out, the "informational message" was pretty misleading, I had the following in my event log.

Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object.
   at MyService.MyService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

Oops.

Fixed that error, and the service starts successfully.

Quick tip: Initialising Dictionary inline

var dictionary = new Dictionary<string, string>
{
{ "key1", "value1" },
{ "key2", "value2" },
{ "key3", "value3" },
};


var list = new List<string>
{
"value1",
"value2",
"value3",
};

You might notice that I like to leave the comma behind the last element in my inline initializers - this is actually unnecessary.  But having it there means that I can copy/paste entire lines and move them around without worrying about missing comma right at the end.


For example, this is valid code:

var list = new List<string>
{
"value1",
"value2",
"value3"
};
But if I had to swap the order of the elements and end up with this code, this is not valid.
var list = new List<string>
{
"value1",
"value3"
"value2",
};