Thursday, 30 April 2009
Do Content Types inherit Event Handlers?
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 ...
The problem? You need to make your class "Public". Doh!
Friday, 17 April 2009
SharePoint Designer 2007 - Released for 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
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, 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
Monday, 12 January 2009
Minus 20 degrees, black runs and (suspected) broken ankles ... guess who's been Skiiing??
Just got back from a brilliant 6 days of Skiing in the Vallenord area of Andorra, which had some absolutely fantastic snow, and a couple of awesome runs :)
I haven't skied for over 10 years (having last been when I was 17 or so) so the chance to strap some metal planks to my feet and throw myself off mountains at 7,000 feet .. I could hardly contain my excitement.
Getting into it all again was a bit tough, remembering my parallels (and trying to keep my feet together ... which I still need more work on!) but by the end of the week we were slaloming in and out of trees on some off-piste alpine fun, and tackling red runs (and a rather terrifying black run) so all in all, a good trip.
The only slight "mishap" was when my wife got startled on a steep blue and managed to hit the only solid object in over 5 miles of snow ... a brand new wooden fence (which she rather spectacularly smashed into .. badly bruising her knee .. and (possibly) breaking her ankle).. queue hobbling down the mountain and muggins here had to carry her skiis back (it is surprising how difficult it is to ski while holding a second pair of skis!)
Oh well .. back in the UK now ... 7000 feet lower and 30 degrees warmer ... back to work I guess.
Monday, 22 December 2008
Delegate Controls - Why you need to delegate!
What are Delegate Controls?
Well .. delegates are basically a new control that can be used in SharePoint (both WSS 3.0 and MOSS 2007) which allow you to render different controls on different sites, using features to switch them on and off.
Sound interesting? Well let me whet your appetite further.
Apart from the fact that you can create your own delegates (hopefully your dev brain boggles already!) but Delegates are already in use in a large number of places in SharePoint:
- Top Navigation Menu Control
- Quick Launch Menu Control
- Search Controls
- My Links / Quick Links controls
- etc ...
I'll say that again, just in case you missed it. You don't need to modify the master page.
The delegate controls are already in the default.master, so you just need to install and activate a feature which tells SharePoint to use your custom control instead of the standard ones!
Neat huh? (I knew you'd like it)
So what kind of controls can I use with Delegates?
You'll like this answer too .... anything.
Yep, any control (either ASCX based user controls, or DLL based server controls) can be dropped into a delegate. All you need is a feature that registers it!
So how does it all work then?
Well .. delegates have 2 parts to them:
- ASP.Net Delegate Control (effectively a placeholder)
- Feature which registers a new ASP.Net control to use in place of the delegate
You only have 1 attribute to worry about; ControlId is basically a unique "name" for your placeholder. The example shown here is for the standard Search control that appears on every page.
After you've got your Delegate Control, you need a feature to implement your actual ASP.Net controls. Luckily the feature is quite straightforward.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="25"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx"
ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="UseSiteDefaults">true</Property>
<Property Name="FrameType">None</Property>
<Property Name="ShowAdvancedSearch">true</Property>
</Control>
</Elements>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
The Id is the same as your "ControlId" property in your Delegate control. Then you either reference a set of Control Class / Control Assembly, or you point it to a relative path to the ASCX control using the ControlSrc property.
Thats it! Once your feature is activated (at whatever scope you choose ... Farm, Application, Site, Web) then your ASP.Net control will appear in place of the delegate!
But what about Sequence??
Ahhh ... well that is where the real beauty of Delegates comes through in a SharePoint environment! As the controls are installed and activated using Features, how do you account for having multiple features at multiple scopes?
The Sequence attribute allows you to offer a number value which will be used when choosing which feature has priority. Simply put, the feature with the lowest sequence number will be rendered.
This allows you to achieve 2 different things:
- Upgrade Path
- Different controls on different sites
In WSS 3.0 this is implemented through a feature with a Sequence of 100. In MOSS 2007 Standard a replacement control was installed with a Sequence of 50. And in MOSS 2007 Enterprise another new control is implemented with a Sequence of 25!
Hopefully you can see the picture, but I'll join the dots anyway!
The same delegate, and the same master page is used in all 3 installs. But as you install a newer version, a replacement feature is activated (with a lower sequence number) which takes preference.
So .. if you wanted to replace the "SmallSearchInputBox" control in a WSS 3.0 system, but wanted the "out of the box" control to come back if they ever install MOSS 2007, then you could register your own feature with a Sequence of anything between 100 and 50.
This same approach can be used if you wanted to replace controls on a specific site. So lets say you want to replace the Quick Launch navigation control in specific web sites. You could create a Web scoped feature, and activate it on those sites that you want to replace the Quick Launch in.
No Master Page, No ASP.Net Web Form dev ... easy.
Wednesday, 3 December 2008
Joining Content & Code as a Solutions Architect! (on Monday)
Ok .. so here is another reason why my posts have been few & far between recently .. yep ... I'm moving on to pastures new, and Friday is my last day at Ratio One!
Thankfully I have not succumb to the dreaded "credit crunch" but have decided to take a fantastic opportunity to join the Solutions Team at Content & Code as one of their Solution Architects, helping to design and scope solutions, aiding the consultants and developers in their technical delivery, drive best practice in the business and also try to get more involved in the SharePoint Community.
What does this mean? Well, I will still be making the same blog posts, and be just as active on the MSDN forums (if not more so!). It also means you'll be seeing a bit more of me at the User Groups and community events around London (and possibly elsewhere in Europe?).
I would also like to take this opportunity to both thank Content & Code for this great opportunity, and also to thank Ratio One for their support over the past 2 (and a bit) years. I've certainly come on a long way since my first forays into SharePoint, and (generally) loved every minute of it!
Tuesday, 2 December 2008
Creating "External" URLs in the Quick Launch menu
This post was prompted by the problems I've been having trying to get header nodes to be added to a site when it is provisioned, which have a custom URL pointing at a different site in the site collection.
Despite the NavBar element in the onet.xml having a URL attribute, this had no effect on my quick launch and it was always created using the current web's URL (i.e. on click it just took me straight to the current web site home page).
So, I embarked on a simple feature which I could use to create those navigation headers.
The code is pretty simple:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
// get the current "Web" object
using (SPWeb web = (SPWeb)properties.Feature.Parent)
{
// create the new navigation node
SPNavigationNode newNode =
new SPNavigationNode("Go to any sub site", "/anysite/anysubsite", true);// add the node to the quicklaunch menu
web.Navigation.QuickLaunch.AddAsLast(newNode);// save the changes
newNode.Update();
}
}
Now, the main thing to note is that when you create your SPNavigationNode object to use the true argument in the constructor!
This tells SharePoint that the URL is an External URL (and by External .. I mean "not in the current web"). If you don't set this then you will get an error telling you that the URL is invalid, or that the page/file cannot be found.
Even if the URL is a relative URL to the same site collection, you still have to set this value to true! Not entirely obvious that one, so one to watch out for.
Sad news ...
Sorry that my activity in the past week has been a bit poor ... but my mother-in-law died last week. I've basically been buried in the subsequent activities (funeral directors, coroner, registrar, church, etc) which was made much harder because my father-in-law is deaf and cannot use the telephone.
Funeral on Thursday .. hopefully be back to my old self by the weekend.