Navigation

Tuesday, 23 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%>

 

XML (CAML)

$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 :D


Thursday, 4 June 2009

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 :)


Friday, 29 May 2009

The many reasons for "Data Is Invalid" in MOSS 2007

Well .. this is something I have been grappling with for about 2 weeks ... one of our test farms started spewing out this error and for the life of me I couldn't work out why.

We were getting it in the following scenarios:
  1. Creating a new Web Application
  2. Installing SharePoint, and running the Products & Technologies Wizard
  3. Adding a new web front end server to an existing Farm
(Note - 2 - the error was when provisioning the Central Admin web application, so similar to point 1)

Now, "Data Invalid" surely points to SQL Server, and to a certain extent that was correct, but not as you might have thought!

It seems that we were getting this error while logging in using an account which does not have both local admin rights and appropriate SQL server permissions!

You would have thought that having Farm Administrator permissions would be enough to create a new web application or add a new web front end, but it appears that the SQL Server permissions break down and it doesn’t work!



Thursday, 30 April 2009

Do Content Types inherit Event Handlers?

Answer ... YES

It's amazing how many people think that this is not the case. What is even more amazing is how many people blindly accept it without actually trying it out themselves.

If you attach an EventReceiver to your Content Type and then create a Child Content Type then the event receiver will still fire on child content types!

The lesson of the day?

A man who asks a question is a fool for 5 minutes ..
A man who asks no questions is a fool for life!

Tuesday, 28 April 2009

Server Could not Create... error with Control Adapters ...

Been writing a lot of Control Adapters recently to override some of the markup generated from SharePoint...

The problem? You need to make your class "Public". Doh!

Friday, 17 April 2009

SharePoint Designer 2007 - Released for FREE

Yep .. took a little while for this one to sink in (it was announced on April 1st!) but SharePoint Designer 2007 (SPD) is now FREE.

SPD gets a lot of stick from the dev communities (who generally prefer Visual Studio) and for source control and effective granular control over the HTML markup I would completely agree, but that's not to say that SPD doesn't have it's place.

I personally find it a great prototyping tool, rapidly creating ASPX pages in such hard-to-reach places (like list forms and views) without going to all the effort of building your own list definitions and getting messy with CAML.

It's also one of the few OOB methods I know of that allows you to easily drag'n'drop field controls on to a page layout, and modify some of the "not-usually-visible" web parts (such as the ListForm and DataForm webparts).

This is all probably academic as Visual Studio 2010 is going to (apparently) include many of the SPD functions. So .. while you wait for the arrival of the (finally) SharePoint friendly Visual Studio 2010 ... go and get SPD! It's FREE! :)

Download Link, Microsoft

Thoughts on the European SharePoint Best Practice Conference - London

I recently attended the Microsoft SharePoint European Best Practice Conference (6th - 8th April 2009) and wanted to share some of my thoughts.
On the whole it was a good event, plenty of top speakers (such as Joel Oleson, Andrew Connell, Eric Shupps, Todd Bleeker ... and many more [full list here]) and certainly lots of topics and tracks to attend .. the event was well organised and catered to all tastes .. but I was left a little bit underwhelmed by the experience.

The Good Bits
The technical sessions (IT Pro and Dev) were excellent, especially the "ask the expert" sessions at the end of each day. These really were an opportunity to get into the nitty gritty of SharePoint with some great topics and questions coming up (some of which even caused disagreements amongst the "experts"!)

A lot of them also tried to grasp some of the more subjective "best practice" topics like content deployment and testing methods. All in all, thoroughly enjoyable, but I did think that there wasn't a massive amount that I didn't already know.

The Bad Bits
The Information Worker and Business Adoption tracks were extremely disappointing. I was expecting a "Best Practice" conference to assume a high level of competence with SharePoint as a starting point, but it seems that the majority of these started off from the "so you've just bought SharePoint .." or the equally dull "so you are thinking about implement SharePoint eh?? .."

There were some exceptions (Penny Coventry did quite a good session around locking down SharePoint Designer, which was quite useful and at the very least an engaging presentation).

But a large amount of the conference was so under-whelming that I actually walked out halfway through a couple of sessions because the "governance" session seemed to be saying "make sure you backup your data" and "don't forget to train your users".. I really couldn't believe how dumbed down a lot of the sessions were.

The BEST bits ...
By far the best parts of the session is to meet and greet people at the conference .. networking was by far the best (and most enjoyable) part of the conference, especially at the "SharePint" sessions in the pub round the corner. Getting to chat to other professionals who are knowledgable and enthusiastic about SharePoint is something that I rarely get treated to outside of my office .. and it is always refreshing to get a new perspective on things.

Highlights:
Andrew Woodward presenting on Test Driven Development
Chris O'Brian presenting on Content Deployment
Andrew Connell on Field Controls & WebParts

and of course .. the "Ask the Experts" sessions


Monday, 16 February 2009

Why my wife rocks :)

Well, the credit crunch is still grinding on, and I am also in the (un)fortunate position of trying to buy a house this month, so pennies are expectedly very tight! So to try and lighten the load my wife (Laura) suggested that she cook me dinner instead!

Well, we cook fresh dinners every night, so I didn't think it would be that special, but I agreed (it's always a good idea to humour the missus!).. was I in for a surprise!

First Course; pan seared scallops, wrapped in parma ham on a bed of shallots with a red wine jus, served with pink champagne.
Main Course: Roast duck breast with a spiced plum sauce, served with baked shallot-mashed potato and mange-tout with a
Dessert: Home made tiramisu, made with brandy and double cream!

Quite possibly one of the most delicious valentines meals I've had in a long long time!

So .. a huge thank you to my wife Red heart! You rock my world Open-mouthed