Monthly Archives: June 2009

Resource files in SharePoint done properly ..

The message I really want to get across … Don’t use Properties/Resources.resx


SharePoint resource files should be stored in one of 2 places (there are other places, but they are not commonly used):


·         12

o   Config

§  Resources ß Location 1 – use this for all Pages, Controls and Web Parts

o   Resources ß Location 2 – use this for all Features, Site Definitions, List Definition, Content Types (i.e. all CAML)


If you need to access those resources from code, then use the following:


C# (programmatically)

String strValue = System.Web.HttpContext.GetGlobalResourceObject(“NameOfResourceFile”, “NameOfProperty”).ToString();


ASPX  Markup

<%$Resources: NameOfResourceFile, NameOfProperty%>



$Resources: NameOfResourceFile, NameOfProperty;

How to setup Internet Connection Sharing and a VPN connection at the same time!

This all came about because I am a guinea pig for the new content and code development environment.
The good news is that I have a spiffy laptop with Dual Core, 4GB DDR2 and (this is the good bit) a 320GB 7200rpm hard drive (not bad for a laptop!).
This all allows me to kick it into gear with Server 2008 x64 and Hyper-V.
Now for the bad news … Hyper-V doesn’t support "Shared Networking (NAT)" even though the technically inferior Virtual PC 2007 DOES!
It’s not too much of a heartache though, you simply have to be creative and setup yourself Internet Connection Sharing. This effectively allows your virtual machine to stay completely hidden from the big wide world, safely behind your an internally facing virtual network and your laptop’s firewall.
This is great for development environments, as we can have stand-alone virtual machines which can be copied, rolled-back and swapped around in minutes without any of that messy sys-prep nonsense.
However .. things went awry when I switched on our VPN … I was at home and didn’t have the creature comforts of a dedicated piece of copper between myself and the server.
I turned on my VPN and it did exactly what it was supposed to .. it created a secure tunnel and promptly shut-down all my other network adapters … including my virtual network…
so … a few hours of troublshooting and chomping of the table edge and I nailed it.
You need to:
  1. Connect to the VPN
  2. Share the VPN connection

This effectively gives your virtual machine it’s own private access to the corporate network .. great for those TFS check-ins and server builds 🙂

*sigh* another one for midnight oil.

Corrupted Control Template : well there’s an error I’ve not seen before!

There I was .. doing some (behind the scenes) coding work on an accessibility project….
and I got this …
Corrupted Control Template. Please check RenderingTemplate of RichImageField in the control template ascx file.

What caused it???

Well … it was admittedly totally my fault. I deleted one of the OOB files in ControlTemplates .. specifically "DefaultTemplates.ascx".
We were working with the field control rendering (like text box, drop-down list .. etc) and I accidentally deleted one of the files.
Still .. at least I’ll know what it is next time 😀

How to select an SPUser, even if they haven’t already been added

This is a nice quick tip.

You want to get an SPUser object for a user account .. the problem is that you don’t know if they have been added to the User Information list yet.

This is especially a problem if an Active Directory Group has been added (and exists in the User Information List) but the actual user hasn’t.

Well, there is an easy solution!

SPWeb.EnsureUser(string LoginName)

Pass in a login name to this method. It will validate it, if it isn’t already added then it will add it to the User Info List and even returns you the SPUser object that represents the specified user!

Enjoy 🙂