Wednesday, May 06, 2009

blog has moved

I decided to move the blog to wordpress, as they have better support for displaying source-code.

to do this I used en excellent utility at

If you were following me (I have no idea if anyone is) you might want to jump to

this will be the last post on this blog-system.


Wednesday, April 29, 2009

Extension methods

Imho: Extension methods should reside in the same namespace as the class they are extending (even if that namespace belongs to the .Net framework or a 3rd. party vendor.) This is the easiest way to keep functionality discoverable in a large solution.

Tuesday, April 28, 2009

Shortcut your environment

The last few months I've spent a conscious effort to speed up my development. I have used resharper since version 1.5 (i think...) but have only recently found a lot of nifty stuff in it here's my favourites:
  • ctrl + n = goto type (classes)
  • ctrl + shift + n = goto file (web.config / language files / aspx / ...)
  • Capitalized shortform (I write CMSG and r# suggests CustomerManagementServiceGateway (a class in our project) to me
These 3 alone amounts to 80% of my increased efficiency. I literally no longer search through the Solution explorer.

I have also used True Launch Bar for my quick menu for a long time.
having all programs I need categorized for easy access, but I started
creating shortcuts for all the relevant folders on all the relevant machines, and that's sped me up quite a bit also. To see the folder where the web project is deployed in the build environment I hover the folder icon on the toolbar which pops up a list of environments, and drill my way in like that, all the icons are easily recognizable ( i set them myself) so to find any relevant place on any environment takes me < .5 secs.

Oh, did I mention I put a shortcut to the hosts-file in there also for each machine?

I cannot recommend enough. takes about an hour to set up the way I want it, but it's totally worth it

Monday, April 27, 2009

Tiny drips of Asp.Net juice

long time no see,

I've been a busy little bee working on a fairly large web site for online gambling (horse races), with some SERIOUSLY cool software/frameworks. Going from the outside in it's been jQuery, EPiServer 5, Asp.Net 3.5, WCF, SOA, NHibernate. And I have learned more from this project than any other. I'm going to publish reference code (for my own later googling pleasure) from this project for quite a while I reckon. I'm starting easy with some webcontrols we have used throughout the solution. using our own has made it possible to enable/utilize jQuery very easily.

to ensure the ID of controls are fixed, we have used this little trick:

public class ClientIdHiddenField: HiddenField


public override string ClientID{ get{ return ID; } }


This enables us to be certain that the jQuery selectors all work as expected

similarly we have overridden labels/buttons/etc to enable us to give the webcontrols a TextKey property (e.g. TextKey="/app/game/gamewindow/buygame" ) declaratively, the TextKey is then used to lookup the correct text from the Translate function in EPiServer

public class TranslateButton: Button



public string TextKey{ get; set; }

protected override void OnPreRender(EventArgs e)


if (!string.IsNullOrEmpty(TextKey) && string.IsNullOrEmpty(Text))


Text = LanguageUtil.TranslateOrBlank(TextKey);





As these are all just Custom Controls (no code-front file) we can specify their namespace in web.config:

[pages validateRequest="false" enableEventValidation="false"]



[add tagPrefix="cc" namespace="OurNamespace.CommonUC" assembly="OurAssemblies.Web" /]



(couldn't get < to work properly in markup here ...)

Monday, December 29, 2008

VS2008 crash on "Choose items" in toolbox

So, today I was trying to include some MS Ajax control toolkit stuff on the web pages I'm building for a client. I right clicked on the toolbox, added a tab and clicked "Choose Items" then VS up and died on me. Lather rinse and repeat.

Obviously something was very wrong here. After some googling I found a solution:
- Start VS from VS command line in safe mode: devenv.exe /safemode
- Click "Choose items" again.
- be sure to click all the tabs in the dialogue
- observe an exception somewhere, and VS will disable the faulty control
- quit the safemode VS.
- restart regular VS and try again

.. VOILA!!

Wednesday, October 08, 2008

string.Format returns the wrong kind of whitespace

ok, this one is weird:

I write a custom util method to format money strings,

it relies on string.Format("{0:n}", someValue).

I cover it with unit tests to verify it works, and when I run them

I get this little gem:

It turns out that the whitespace returned from string.Format is character 160, whereas the whitespace you normally get is character 32.

So I change my method to replace all char 160 into char 32, and voila! all the tests pass...

what's up with that? I didn't even know there were two chars in .Net that both returned whitespace...

Sunday, August 31, 2008

changing the class item template in VS2008

It's been bugging me for too long, every bloody time I go new -> class in VS2008,
I get a class that is not set to public. I usually don't realize until I try to use the class at some later time.

Today I finally snapped and fixed it.

To change the template that is used to create new empty classes in VS2008,
- Go to 
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033
- unzip the
- change the class.cs file
- zip it back up and replace the original .zip file.

In yo face VS2008 default settings!!